-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from baktrius/tests-fix
Tests fix
- Loading branch information
Showing
58 changed files
with
167 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef TEST_H | ||
#define TEST_H | ||
#include <unistd.h> | ||
#include <assert.h> | ||
|
||
#define SUCCESS_MARKER "<<success>>\n" | ||
|
||
int test_success() | ||
{ | ||
// below unchecked syscall return code | ||
write(STDERR_FILENO, SUCCESS_MARKER, sizeof(SUCCESS_MARKER)); | ||
return 0; | ||
} | ||
|
||
#define test_assert(expr) assert(expr && "<<error>>") | ||
|
||
#endif // TEST_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Print help usage if there are fewer then 3 positional arguments | ||
if [ $# -lt 3 ] ; then | ||
echo "Usage: $0 TIMEOUT NUM_OF_WORKERS PATH_TO_PROG [ADDITIONAL_ARGS]" | ||
exit 1 | ||
fi | ||
|
||
# Read important values from positional args into named vars | ||
TIMEOUT=$1 | ||
NUM_OF_WORKERS=$2 | ||
shift 2 | ||
|
||
# Create temporary file | ||
tmp_file=$(mktemp) | ||
|
||
# Invoke mimpirun with appropriate timeout and arguments | ||
# "|| true" used to ignore ./mimpirun return code | ||
timeout "$TIMEOUT" ./mimpirun "$NUM_OF_WORKERS" "$@" 2> "$tmp_file" || true | ||
|
||
result=0 | ||
|
||
# Check if all workers finished successfully | ||
# - num of <<success>> is equal to number of created workers | ||
test "$(grep -c '<<success>>' "$tmp_file")" -ne "$NUM_OF_WORKERS" && result=3 | ||
|
||
# Check if error has been detected - <<error>> was found in stderr | ||
grep "<<error>>" "$tmp_file" > /dev/null && result=2 | ||
|
||
# Print stderr in case of error | ||
test "$result" -ne 0 && cat "$tmp_file" >&2 | ||
|
||
# Remove temporary file | ||
rm "$tmp_file" | ||
|
||
# Exit with appropriate return code | ||
exit "$result" |
Oops, something went wrong.