run_c_binding_test.sh 752 B

123456789101112131415161718192021222324
  1. python3 preprocess.py
  2. echo "compiling c++ lib"
  3. clang++ -c -o pocketpy_c.o c_bindings/pocketpy_c.cpp -Wfatal-errors --std=c++17 -O2 -Wall -Wno-sign-compare -Wno-unused-variable -fno-rtti -stdlib=libc++ -I src/ -g
  4. echo "compiling c executable"
  5. clang -c -o test.o c_bindings/test.c -Wfatal-errors -O2 -Wall -Wno-sign-compare -Wno-unused-variable -I src/ -g
  6. echo "linking"
  7. clang++ -o c_binding_test test.o pocketpy_c.o -stdlib=libc++ -g
  8. ./c_binding_test > binding_test_scratch
  9. echo "checking results (they should be identical)"
  10. diff -q -s binding_test_scratch c_bindings/test_answers.txt
  11. if [ $? -eq 1 ]
  12. then
  13. echo "ERROR: c binding test failed"
  14. exit 1
  15. fi
  16. echo "cleaning up"
  17. rm pocketpy_c.o
  18. rm test.o
  19. rm binding_test_scratch
  20. rm c_binding_test