Skip to content

Instantly share code, notes, and snippets.

@diffs
Created February 7, 2022 21:40
Show Gist options
  • Save diffs/a9a0c3677353854682ef80ef795b61bb to your computer and use it in GitHub Desktop.
Save diffs/a9a0c3677353854682ef80ef795b61bb to your computer and use it in GitHub Desktop.
encodeInput test script
# YOU NEED TO HAVE YOUR 4 SEAN-PROVIDED TEST FILES IN THE SAME DIRECTORY AS THIS SCRIPT
# ALSO, RUN THIS SCRIPT FROM THE SAME LOCATION WHERE YOUR MAKEFILE IS
echo Making...
make clean
make
# FILE 1 RUNS
cat binary-sample-01.bin | ./bin/encodeInput > binary-sample-01.bin.test1
cat binary-sample-01.bin | ./bin/encodeInput -srec > binary-sample-01.bin.test2
cat binary-sample-01.bin | ./bin/encodeInput -obinary-sample-01.bin.test3
cat binary-sample-01.bin | ./bin/encodeInput -srec -obinary-sample-01.bin.test4
./bin/encodeInput -srec -obinary-sample-01.bin.test5 -ibinary-sample-01.bin
./bin/encodeInput -obinary-sample-01.bin.test6 -ibinary-sample-01.bin
# FILE 1 TESTS
echo **Now Testing: File 1**
F1R1=$(diff -s binary-sample-01.bin.test2 binary-sample-01.srec)
F1R2=$(diff -s binary-sample-01.bin.test4 binary-sample-01.srec)
F1R3=$(diff -s binary-sample-01.bin.test5 binary-sample-01.srec)
F1R4=$(sha1sum binary-sample-01.bin.test1)
F1R5=$(sha1sum binary-sample-01.bin.test3)
F1R6=$(sha1sum binary-sample-01.bin.test6)
if [[ "$F1R1" == "1c1"* ]]; then
echo "Test Passed: F1R1";
else
echo "Test FAILED: F1R1";
fi
if [[ "$F1R2" == "1c1"* ]]; then
echo "Test Passed: F1R2";
else
echo "Test FAILED: F1R2";
fi
if [[ "$F1R3" == "1c1"* ]]; then
echo "Test Passed: F1R3";
else
echo "Test FAILED: F1R3";
fi
if [[ "$F1R4" == "6b993ade7eb4096ea00179c6a8b8b46306942bfa"* ]]; then
echo "Test Passed: F1R4";
else
echo "Test FAILED: F1R4";
fi
if [[ "$F1R5" == "6b993ade7eb4096ea00179c6a8b8b46306942bfa"* ]]; then
echo "Test Passed: F1R5";
else
echo "Test FAILED: F1R5";
fi
if [[ "$F1R6" == "6b993ade7eb4096ea00179c6a8b8b46306942bfa"* ]]; then
echo "Test Passed: F1R6";
else
echo "Test FAILED: F1R6";
fi
# FILE 2 RUNS
cat binary-sample-02.bin | ./bin/encodeInput > binary-sample-02.bin.test1
cat binary-sample-02.bin | ./bin/encodeInput -srec > binary-sample-02.bin.test2
cat binary-sample-02.bin | ./bin/encodeInput -obinary-sample-02.bin.test3
cat binary-sample-02.bin | ./bin/encodeInput -srec -obinary-sample-02.bin.test4
./bin/encodeInput -srec -obinary-sample-02.bin.test5 -ibinary-sample-02.bin
./bin/encodeInput -obinary-sample-02.bin.test6 -ibinary-sample-02.bin
# FILE 1 TESTS
echo **Now Testing: File 2**
F2R1=$(diff -s binary-sample-02.bin.test2 binary-sample-02.srec)
F2R2=$(diff -s binary-sample-02.bin.test4 binary-sample-02.srec)
F2R3=$(diff -s binary-sample-02.bin.test5 binary-sample-02.srec)
F2R4=$(sha1sum binary-sample-02.bin.test1)
F2R5=$(sha1sum binary-sample-02.bin.test3)
F2R6=$(sha1sum binary-sample-02.bin.test6)
if [[ "$F2R1" == "1c1"* ]]; then
echo "Test Passed: F2R1";
else
echo "Test FAILED: F2R1";
fi
if [[ "$F2R2" == "1c1"* ]]; then
echo "Test Passed: F2R2";
else
echo "Test FAILED: F2R2";
fi
if [[ "$F2R3" == "1c1"* ]]; then
echo "Test Passed: F2R3";
else
echo "Test FAILED: F2R3";
fi
if [[ "$F2R4" == "620e044e58c3e4f6b382f70a45324080b48c4f5b"* ]]; then
echo "Test Passed: F2R4";
else
echo "Test FAILED: F2R4";
fi
if [[ "$F2R5" == "620e044e58c3e4f6b382f70a45324080b48c4f5b"* ]]; then
echo "Test Passed: F2R5";
else
echo "Test FAILED: F2R5";
fi
if [[ "$F2R6" == "620e044e58c3e4f6b382f70a45324080b48c4f5b"* ]]; then
echo "Test Passed: F2R6";
else
echo "Test FAILED: F2R6";
fi
# OTHER
echo **Now Testing: Wonderland**
WONDERLAND=$(curl -s https://cdn.discordapp.com/attachments/843626423843422208/933794057300361277/wonderland.txt | ./bin/encodeInput | sha1sum)
if [[ "$WONDERLAND" == "26c4eb8398ce1633cd9a56cb7184811eb856e0b2"* ]]; then
echo "Test Passed: Wonderland";
else
echo "Test FAILED: Wonderland [$WONDERLAND]";
fi
rm -rf binary-sample-0?.bin.test?
@diffs
Copy link
Author

diffs commented Feb 7, 2022

  1. Browse to your project folder (top-level, same location as your makefile)
  2. Download this script
  3. Download and extract the 4 Sean testing files into the same directory, if they are not there already*
  4. Run the command: chmod +x a2test.sh to give the script permissions to execute
  5. Install a required utility, curl, in case it is not already installed: sudo apt install curl
    (you only need to do that once)
  6. Run the script: ./a2test.sh

You should get an output that should look something like this:

Making...

**Now Testing: File 1**
Test Passed: F1R1
Test Passed: F1R2
Test Passed: F1R3
Test Passed: F1R4
Test Passed: F1R5
Test Passed: F1R6
**Now Testing: File 2**
Test Passed: F2R1
Test Passed: F2R2
Test Passed: F2R3
Test Passed: F2R4
Test Passed: F2R5
Test Passed: F2R6
**Now Testing: Wonderland**
Test Passed: Wonderland

*Your top-level directory should have (at least) all these files before running the script:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment