c++.exp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. load_lib libgomp-dg.exp
  2. load_gcc_lib gcc-dg.exp
  3. global shlib_ext
  4. set shlib_ext [get_shlib_extension]
  5. set lang_link_flags "-lstdc++"
  6. set lang_test_file_found 0
  7. set lang_library_path "../libstdc++-v3/src/.libs"
  8. if [info exists lang_include_flags] then {
  9. unset lang_include_flags
  10. }
  11. # If a testcase doesn't have special options, use these.
  12. if ![info exists DEFAULT_CFLAGS] then {
  13. set DEFAULT_CFLAGS "-O2"
  14. }
  15. # Initialize dg.
  16. dg-init
  17. # Turn on OpenMP.
  18. lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
  19. # Switch into C++ mode. Otherwise, the libgomp.c-c++-common/*.c
  20. # files would be compiled as C files.
  21. set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
  22. set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
  23. set blddir [lookfor_file [get_multilibs] libgomp]
  24. if { $blddir != "" } {
  25. # Look for a static libstdc++ first.
  26. if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
  27. set lang_test_file "${lang_library_path}/libstdc++.a"
  28. set lang_test_file_found 1
  29. # We may have a shared only build, so look for a shared libstdc++.
  30. } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
  31. set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}"
  32. set lang_test_file_found 1
  33. } else {
  34. puts "No libstdc++ library found, will not execute c++ tests"
  35. }
  36. } elseif { [info exists GXX_UNDER_TEST] } {
  37. set lang_test_file_found 1
  38. # Needs to exist for libgomp.exp.
  39. set lang_test_file ""
  40. } else {
  41. puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
  42. }
  43. if { $lang_test_file_found } {
  44. # Gather a list of all tests.
  45. set tests [lsort [concat \
  46. [find $srcdir/$subdir *.C] \
  47. [find $srcdir/$subdir/../libgomp.c-c++-common *.c]]]
  48. if { $blddir != "" } {
  49. set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
  50. } else {
  51. set ld_library_path "$always_ld_library_path"
  52. }
  53. append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
  54. set_ld_library_path_env_vars
  55. set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
  56. if { [file exists $flags_file] } {
  57. set libstdcxx_includes [exec sh $flags_file --build-includes]
  58. } else {
  59. set libstdcxx_includes ""
  60. }
  61. # Main loop.
  62. dg-runtest $tests "" "$libstdcxx_includes $DEFAULT_CFLAGS"
  63. }
  64. # See above.
  65. set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
  66. # All done.
  67. dg-finish