test_native.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #-------------------------------------------------------------------------------------------------------
  2. # Copyright (C) Microsoft. All rights reserved.
  3. # Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. #-------------------------------------------------------------------------------------------------------
  5. CH_DIR=$1
  6. RES=
  7. CC=0
  8. CXX=0
  9. FIND_CLANG() {
  10. for i in 7 8 9
  11. do
  12. if [[ -f "/usr/bin/clang-3.${i}" ]]; then
  13. CC="/usr/bin/clang-3.${i}"
  14. CXX="/usr/bin/clang++-3.${i}"
  15. fi
  16. done
  17. if [[ $CC == 0 ]]; then
  18. echo "Error: Couldn't find Clang"
  19. exit 1
  20. fi
  21. }
  22. SAFE_RUN() {
  23. local SF_RETURN_VALUE=$($1 2>&1)
  24. if [[ $? != 0 ]]; then
  25. >&2 echo $SF_RETURN_VALUE
  26. exit 1
  27. fi
  28. }
  29. TEST () {
  30. if [[ $RES =~ $1 ]]; then
  31. echo "${TEST_PATH} : PASS"
  32. else
  33. echo "${TEST_PATH} FAILED"
  34. echo -e "$RES"
  35. exit 1
  36. fi
  37. }
  38. RES=$(c++ --version)
  39. if [[ ! $RES =~ "Apple LLVM" ]]; then
  40. FIND_CLANG
  41. else
  42. CC="cc"
  43. CXX="c++"
  44. fi
  45. RUN () {
  46. TEST_PATH=$1
  47. echo "Testing $TEST_PATH"
  48. SAFE_RUN `cd $TEST_PATH; ${CH_DIR} Platform.js > Makefile`
  49. RES=$(cd $TEST_PATH; cat Makefile)
  50. if [[ $RES =~ "# IGNORE_THIS_TEST" ]]; then
  51. echo "Ignoring $TEST_PATH"
  52. else
  53. SAFE_RUN `cd $TEST_PATH; make CC=${CC} CXX=${CXX}`
  54. RES=$(cd $TEST_PATH; ./sample.o)
  55. TEST "SUCCESS"
  56. SAFE_RUN `cd $TEST_PATH; rm -rf ./sample.o`
  57. fi
  58. }
  59. # test-char16
  60. RUN "test-char16"
  61. # test-static-native
  62. RUN "test-static-native"
  63. SAFE_RUN `rm -rf Makefile`