run_c_binding_test.sh 786 B

1234567891011121314151617181920212223242526
  1. python3 preprocess.py
  2. echo "compiling c++ lib"
  3. clang++ -c -o pocketpy_c.o c_bindings/pocketpy_c.cpp -Wfatal-errors -O1 --std=c++17 -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 -Wall -O1 -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. rm pocketpy_c.o
  15. rm test.o
  16. exit 1
  17. fi
  18. echo "cleaning up"
  19. rm pocketpy_c.o
  20. rm test.o
  21. rm binding_test_scratch
  22. rm c_binding_test