aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target
diff options
context:
space:
mode:
authorJozef Lawrynowicz <jozef.l@mittosystems.com>2019-11-04 11:01:03 +0000
committerJozef Lawrynowicz <jozefl@gcc.gnu.org>2019-11-04 11:01:03 +0000
commitd7eabfd452f6f447ca8f3a955e7a4b531884fadb (patch)
tree7654a0733dcf2cd4ab85896373c854912bda4b7c /gcc/testsuite/gcc.target
parentb76f4e6c06bd494d2383c4c16d1e1a034da74641 (diff)
downloadgcc-d7eabfd452f6f447ca8f3a955e7a4b531884fadb.zip
gcc-d7eabfd452f6f447ca8f3a955e7a4b531884fadb.tar.gz
gcc-d7eabfd452f6f447ca8f3a955e7a4b531884fadb.tar.bz2
MSP430: Add new methods of finding external MCU data file
MCU data file can now be specified with an environment variable or installed into a toolchain subdirectory. 2019-11-04 Jozef Lawrynowicz <jozef.l@mittosystems.com> gcc/ * config/msp430/driver-msp430.c (msp430_get_linker_devices_include_path): New spec function. * config/msp430/msp430-devices.c (msp430_dirname): New function. (extract_devices_dir_from_exec_prefix): New function. (extract_devices_dir_from_collect_gcc): New function. (msp430_check_env_var_for_devices): New function. (msp430_check_path_for_devices): Use xstrdup instead of ASTRDUP. (parse_devices_csv): Call msp430_check_env_var_for_devices if devices.csv was not found using other methods. * config/msp430/msp430-devices.h (msp430_check_env_var_for_devices): New prototype. (msp430_dirname): Likewise. * config/msp430/msp430.c (msp430_register_pre_includes): New function. * config/msp430/msp430.h (EXTRA_SPEC_FUNCTIONS): Add msp430_get_linker_devices_include_path. (TARGET_EXTRA_PRE_INCLUDES): Define. * doc/invoke.texi: Document new ways of searching for support files. gcc/testsuite/ * gcc.target/msp430/devices/csv-using-env-var.c: New test. * gcc.target/msp430/devices/csv-using-installed.c: New test. * gcc.target/msp430/devices/csv-using-option.c: New test. * gcc.target/msp430/devices/devices-main.c: New test source file. * gcc.target/msp430/devices/msp430-devices.h: New test. * gcc.target/msp430/msp430.exp (msp430_device_permutations_runtest): Add special cases for csv-using* tests. Define TESTING_HARD_DATA when running tests that use hard-coded device data. (get_installed_device_data_path): New. (msp430_hide_installed_devices_data): New. (msp430_restore_installed_devices_data): New. (msp430_test_installed_device_data): New. (msp430_install_device_data): New. From-SVN: r277772
Diffstat (limited to 'gcc/testsuite/gcc.target')
-rw-r--r--gcc/testsuite/gcc.target/msp430/devices/csv-using-env-var.c10
-rw-r--r--gcc/testsuite/gcc.target/msp430/devices/csv-using-installed.c9
-rw-r--r--gcc/testsuite/gcc.target/msp430/devices/csv-using-option.c9
-rw-r--r--gcc/testsuite/gcc.target/msp430/devices/devices-main.c4
-rw-r--r--gcc/testsuite/gcc.target/msp430/devices/msp430-devices.h3
-rw-r--r--gcc/testsuite/gcc.target/msp430/msp430.exp94
6 files changed, 127 insertions, 2 deletions
diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv-using-env-var.c b/gcc/testsuite/gcc.target/msp430/devices/csv-using-env-var.c
new file mode 100644
index 0000000..f2c30ee
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices/csv-using-env-var.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mmcu=msp430_28" } */
+/* { dg-warning "supports 430X ISA but '-mcpu' option is set to 430" "" { target msp430_430_selected } 0 } */
+/* { dg-warning "supports f5series hardware multiply" "" { target msp430_hwmul_not_f5 } 0 } */
+
+/* This tests that the environment variable MSP430_GCC_INCLUDE_DIR can be used
+ to specify the path to the directory containing devices.csv.
+ The variable is set in msp430.exp. */
+
+#include "devices-main.c"
diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv-using-installed.c b/gcc/testsuite/gcc.target/msp430/devices/csv-using-installed.c
new file mode 100644
index 0000000..11cbbab
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices/csv-using-installed.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mmcu=msp430_28" } */
+/* { dg-warning "supports 430X ISA but '-mcpu' option is set to 430" "" { target msp430_430_selected } 0 } */
+/* { dg-warning "supports f5series hardware multiply" "" { target msp430_hwmul_not_f5 } 0 } */
+
+/* This tests that devices.csv can be installed into the
+ "$TOOLCHAIN_ROOT/msp430-elf/include/devices/" and used to read device data. */
+
+#include "devices-main.c"
diff --git a/gcc/testsuite/gcc.target/msp430/devices/csv-using-option.c b/gcc/testsuite/gcc.target/msp430/devices/csv-using-option.c
new file mode 100644
index 0000000..bb47d53
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices/csv-using-option.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mmcu=msp430_28" } */
+/* { dg-warning "supports 430X ISA but '-mcpu' option is set to 430" "" { target msp430_430_selected } 0 } */
+/* { dg-warning "supports f5series hardware multiply" "" { target msp430_hwmul_not_f5 } 0 } */
+
+/* This tests that the -mdevices-csv-loc option can be used to specify the path
+ to devices.csv. */
+
+#include "devices-main.c"
diff --git a/gcc/testsuite/gcc.target/msp430/devices/devices-main.c b/gcc/testsuite/gcc.target/msp430/devices/devices-main.c
index 20448f4..8af6ec1 100644
--- a/gcc/testsuite/gcc.target/msp430/devices/devices-main.c
+++ b/gcc/testsuite/gcc.target/msp430/devices/devices-main.c
@@ -1,3 +1,7 @@
+#ifndef TESTING_HARD_DATA
+#include <msp430-devices.h>
+#endif
+
int
main (void)
{
diff --git a/gcc/testsuite/gcc.target/msp430/devices/msp430-devices.h b/gcc/testsuite/gcc.target/msp430/devices/msp430-devices.h
new file mode 100644
index 0000000..105bd2b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/devices/msp430-devices.h
@@ -0,0 +1,3 @@
+#ifndef __MSP430__
+#error
+#endif
diff --git a/gcc/testsuite/gcc.target/msp430/msp430.exp b/gcc/testsuite/gcc.target/msp430/msp430.exp
index bcc5686..3758661 100644
--- a/gcc/testsuite/gcc.target/msp430/msp430.exp
+++ b/gcc/testsuite/gcc.target/msp430/msp430.exp
@@ -101,6 +101,25 @@ proc msp430_device_permutations_runtest { tests } {
if { ![runtest_file_p $runtests $test_file] } {
continue
}
+ # The device name passed to -mmcu in the csv-using-* tests do not exist
+ # in the hard-coded data, to ensure the test fails if the method can't
+ # find the device data.
+ if { [file tail $test_file] eq "csv-using-installed.c" } {
+ msp430_test_installed_device_data $test_file $MSP430_DEFAULT_CFLAGS
+ continue
+ } elseif { [file tail $test_file] eq "csv-using-option.c" } {
+ dg-runtest $test_file \
+ "-mdevices-csv-loc=[file dirname $test_file]/devices.csv" \
+ "$MSP430_DEFAULT_CFLAGS"
+ continue
+ } elseif { [file tail $test_file] eq "csv-using-env-var.c" } {
+ setenv MSP430_GCC_INCLUDE_DIR [file dirname $test_file]
+ verbose -log "MSP430_GCC_INCLUDE_DIR=[file dirname $test_file]"
+ dg-runtest $test_file "" "$MSP430_DEFAULT_CFLAGS"
+ setenv MSP430_GCC_INCLUDE_DIR ""
+ verbose -log "MSP430_GCC_INCLUDE_DIR=\"\""
+ continue
+ }
foreach { mcu_flags } [msp430_get_opts $test_file] {
if { [string match "csv-*" [file tail $test_file]] } {
# Specify the path to devices.csv for devices/csv-* tests with -I.
@@ -115,12 +134,76 @@ proc msp430_device_permutations_runtest { tests } {
} elseif { [string match "bad-devices*" [file tail $test_file]] } {
dg-runtest $test_file "$mcu_flags" "-mdevices-csv-loc=[file dirname $test_file]/[file tail $test_file]sv $MSP430_DEFAULT_CFLAGS"
} else {
- dg-runtest $test_file "$mcu_flags" "$MSP430_DEFAULT_CFLAGS"
+ dg-runtest $test_file "$mcu_flags -DTESTING_HARD_DATA" "$MSP430_DEFAULT_CFLAGS"
}
- }
+ }
+ }
+}
+
+
+# Return $TOOLCHAIN_ROOT/msp430-elf/include/devices/
+proc get_installed_device_data_path { } {
+ set compiler [lindex [regexp -all -inline {\S+} \
+ [board_info [target_info name] compiler]] 0]
+ # $compiler is actually a file, but normalize will still get us the desired
+ # result.
+ return [file normalize \
+ "$compiler/../../msp430-elf/include/devices/devices.csv"]
+}
+
+# If the devices.csv is installed in
+# $TOOLCHAIN_ROOT/msp430-elf/include/devices/, rename it so it doesn't
+# interfere with the hard-coded device data tests.
+proc msp430_hide_installed_devices_data { } {
+ set devices_path [get_installed_device_data_path]
+ if { [file exists $devices_path] } {
+ file rename $devices_path "$devices_path.bak"
}
}
+# Restore devices.csv if renamed by msp430_hide_installed_devices_data.
+proc msp430_restore_installed_devices_data { } {
+ set devices_path [get_installed_device_data_path]
+ if { [file exists "$devices_path.bak"] } {
+ file rename "$devices_path.bak" $devices_path
+ }
+}
+
+proc msp430_test_installed_device_data { name default_cflags } {
+ global subdir
+ global env
+
+ # The initial value for GCC_EXEC_PREFIX set by target-libpath.exp is not
+ # correct for cross-compilers so fix it here. GCC fixes the value itself,
+ # but not after spec functions are executed, which can cause a warning
+ # about missing devices.csv to be emitted.
+ set compiler [lindex [regexp -all -inline {\S+} \
+ [board_info [target_info name] compiler]] 0]
+ set real_exec_prefix "[file normalize "$compiler/../../lib/gcc"]/"
+ setenv GCC_EXEC_PREFIX $real_exec_prefix
+
+ msp430_restore_installed_devices_data
+ set devices_path [get_installed_device_data_path]
+ if { [file exists $devices_path] } {
+ dg-runtest $name "" "$default_cflags"
+ } else {
+ set shorter_name "$subdir/[file tail $name]"
+ verbose -log "$shorter_name not supported, $devices_path doesn't exist."
+ unsupported $shorter_name
+ }
+ msp430_hide_installed_devices_data
+}
+
+proc msp430_install_device_data { testsuite_dir } {
+ set devices_path [get_installed_device_data_path]
+ if { [file exists $devices_path] } {
+ return
+ }
+ set installed_path [file dirname $devices_path]
+ file mkdir $installed_path
+ file copy $testsuite_dir/msp430-devices.h $testsuite_dir/devices.csv $installed_path
+}
+
# Load support procs.
load_lib gcc-dg.exp
@@ -138,11 +221,18 @@ if [info exists DEFAULT_CFLAGS] then {
# Initialize `dg'.
dg-init
+# Install then hide the devices data now, in case it is already installed. We
+# don't want it to interfere with tests until we need it to.
+msp430_install_device_data $srcdir/$subdir/devices
+msp430_hide_installed_devices_data
+
# Main loop.
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
"" $MSP430_DEFAULT_CFLAGS
msp430_device_permutations_runtest [lsort [glob -nocomplain $srcdir/$subdir/devices/*.\[cCS\]]]
+msp430_restore_installed_devices_data
+
# All done.
dg-finish