Created
May 29, 2014 15:32
-
-
Save michaelpeternell/e56bad856884816e4366 to your computer and use it in GitHub Desktop.
Simple test case to check if GNU Cobol is actually installed
This file contains hidden or 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
#!/bin/bash | |
# Created: 2014-May-29 | |
# by Michael Peternell ( michael dot peternell at gmx dot at ) | |
# License: you may use it if you promise to never ever sue me for anything | |
# anytime, even if this script causes your computer to explode ;) | |
# This test case succeeds (returns 0) if the GNU Cobol compiler (cobc) is | |
# installed and if it can compile a simple hello world program | |
rm -rf t001_tmp | |
mkdir t001_tmp | |
if (($? > 0)); then | |
echo T001: Cannot create temp-dir | |
exit 1 | |
fi | |
cd t001_tmp | |
echo ' * Sample COBOL program | |
IDENTIFICATION DIVISION. | |
PROGRAM-ID. hello. | |
PROCEDURE DIVISION. | |
DISPLAY "Hello World!". | |
STOP RUN.' >hello.cob | |
echo "Hello World!" >expected_output.txt | |
cobc -x hello.cob 2>&1 | tee compile_output.txt | |
test -f hello | |
if (($? > 0)); then | |
echo T001: Cannot compile hello world | |
exit 1 | |
fi | |
./hello 2>&1 > actual_output.txt | |
if (($? > 0)); then | |
echo T001: Cannot run hello world | |
exit 1 | |
fi | |
diff actual_output.txt expected_output.txt >/dev/null | |
if (($? > 0)); then | |
echo T001: Unexpected output of hello world program | |
exit 1 | |
fi | |
# Success | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment