From 9e7f4c9d43b310c280cd6432cd4150411f4b914e Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 14 Nov 2020 22:06:10 +0100 Subject: Added system tests --- systemtest/config/unix.exp | 19 +++++++++++++++++++ systemtest/mcc-execute.tests/exitcodes.exp | 17 ++--------------- systemtest/mcc-execute.tests/test-addition.cpp | 1 + systemtest/mcc-execute.tests/test-return-1.cpp | 1 + systemtest/mcc-execute.tests/test.cpp | 1 - systemtest/mcc-execute.tests/test1.cpp | 1 - 6 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 systemtest/mcc-execute.tests/test-addition.cpp create mode 100644 systemtest/mcc-execute.tests/test-return-1.cpp delete mode 100644 systemtest/mcc-execute.tests/test.cpp delete mode 100644 systemtest/mcc-execute.tests/test1.cpp (limited to 'systemtest') diff --git a/systemtest/config/unix.exp b/systemtest/config/unix.exp index e69de29..2de93b0 100644 --- a/systemtest/config/unix.exp +++ b/systemtest/config/unix.exp @@ -0,0 +1,19 @@ +proc runtest_exit_code { test_name command_line exit_code } { + + spawn $command_line + + expect eof + + lassign [wait] pid spawnid os_error_flag value + + if {$os_error_flag == 0} { + if {$value == $exit_code} { + pass "$test_name: Returned expected value $value" + } else { + fail "$test_name: Returned bad value $value, expected: $exit_code" + } + } else { + fail "$test_name: errno: $value" + } + +} diff --git a/systemtest/mcc-execute.tests/exitcodes.exp b/systemtest/mcc-execute.tests/exitcodes.exp index 6e8b632..48d19a1 100644 --- a/systemtest/mcc-execute.tests/exitcodes.exp +++ b/systemtest/mcc-execute.tests/exitcodes.exp @@ -1,18 +1,5 @@ # https://www.embecosm.com/appnotes/ean8/ean8-howto-dejagnu-1.0.html -spawn systemtest/mcc-execute.tests/test1 - -expect eof - -lassign [wait] pid spawnid os_error_flag value - -if {$os_error_flag == 0} { - if {$value == 3} { - pass "exit status: $value" - } else { - fail "exit status: $value" - } -} else { - fail "errno: $value" -} +runtest_exit_code "Return 1" "systemtest/mcc-execute.tests/test-return-1" 1 +runtest_exit_code "Addition" "systemtest/mcc-execute.tests/test-addition" 3 diff --git a/systemtest/mcc-execute.tests/test-addition.cpp b/systemtest/mcc-execute.tests/test-addition.cpp new file mode 100644 index 0000000..3a03f6f --- /dev/null +++ b/systemtest/mcc-execute.tests/test-addition.cpp @@ -0,0 +1 @@ +int main() { return 1 + 2; } diff --git a/systemtest/mcc-execute.tests/test-return-1.cpp b/systemtest/mcc-execute.tests/test-return-1.cpp new file mode 100644 index 0000000..40cbb54 --- /dev/null +++ b/systemtest/mcc-execute.tests/test-return-1.cpp @@ -0,0 +1 @@ +int main() { return 1; } diff --git a/systemtest/mcc-execute.tests/test.cpp b/systemtest/mcc-execute.tests/test.cpp deleted file mode 100644 index 40cbb54..0000000 --- a/systemtest/mcc-execute.tests/test.cpp +++ /dev/null @@ -1 +0,0 @@ -int main() { return 1; } diff --git a/systemtest/mcc-execute.tests/test1.cpp b/systemtest/mcc-execute.tests/test1.cpp deleted file mode 100644 index 3a03f6f..0000000 --- a/systemtest/mcc-execute.tests/test1.cpp +++ /dev/null @@ -1 +0,0 @@ -int main() { return 1 + 2; } -- cgit v1.2.3