+2019-11-19  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * gdb.base/ctf-constvars.exp: Skip test if CTF is not supported in
+       the compiler.  Clean up header comment a little.
+       * gdb.base/ctf-ptype.exp: Likewise.
+       * gdb.base/ctf-whatis.exp: Likewise.
+       * lib/gdb.exp (skip_ctf_tests): New proc.
+
 2019-11-18  Sergio Durigan Junior  <sergiodj@redhat.com>
 
        https://bugzilla.redhat.com/show_bug.cgi?id=1765117
 
 #
 # This file is part of the gdb testsuite
 #
-# tests for const variables
-#           const pointers to vars
-#           pointers to const variables
-#           const pointers to const vars
-# with mixed types
+# Tests for: const variables,
+#            const pointers to vars
+#            pointers to const variables
+#            const pointers to const vars
+# with mixed types.
 
-#
-# test running programs
-#
-# -gt generates full-fledged CTF.
+if [skip_ctf_tests] {
+    unsupported "no ctf debug format support"
+    return 0
+}
 
 standard_testfile .c
-set opts "additional_flags=-gt"
 
+# Using `-gt` generates full-fledged CTF debug information.
+set opts "additional_flags=-gt"
 if { [prepare_for_testing "failed to prepare" ${testfile} \
          [list $srcfile] [list $opts nowarnings]] } {
     return 0
 
 
 # This file is a subset of ptype.exp written by Rob Savoye. (rob@cygnus.com)
 
-#
-# test running programs
-#
-# -gt generates full-fledged CTF.
+if [skip_ctf_tests] {
+    unsupported "no ctf debug format support"
+    return 0
+}
 
 standard_testfile .c
-set opts "additional_flags=-gt"
 
+# Using `-gt` generates full-fledged CTF debug information.
+set opts "additional_flags=-gt"
 if { [prepare_for_testing "failed to prepare" ${testfile} \
          [list $srcfile] [list $opts nowarnings]] } {
     return 0
 
 
 # This file is a subset of whatis.exp written by Rob Savoye. (rob@cygnus.com)
 
-#
-# test running programs
-#
-# -gt generates full-fledged CTF.
+if [skip_ctf_tests] {
+    unsupported "no ctf debug format support"
+    return 0
+}
 
 standard_testfile .c
-set opts "additional_flags=-gt"
 
+# Using `-gt` generates full-fledged CTF debug information.
+set opts "additional_flags=-gt"
 if { [prepare_for_testing "failed to prepare" ${testfile} \
           [list $srcfile] [list $opts nowarnings]] } {
     return 0
 
     }
 }
 
+# Does the compiler support CTF debug output using '-gt' compiler
+# flag?  If not then we should skip these tests.
+
+gdb_caching_proc skip_ctf_tests {
+    return ![gdb_can_simple_compile ctfdebug {
+       int main () {
+           return 0;
+       }
+    } executable "additional_flags=-gt"]
+}
+
 # Always load compatibility stuff.
 load_lib future.exp