From 0b2170987c2e16f2137913b9aa0a4e29453cbc57 Mon Sep 17 00:00:00 2001 From: Giuliano Belinassi Date: Wed, 27 May 2020 20:38:08 -0300 Subject: Add test for driver This commit adds some tests to the `gcc' driver, which are already covered by bootstrap. However, here we have a quick way of testing things. gcc/testsuite/ChangeLog 2020-05-27 Giuliano Belinassi * gcc.dg/driver/driver.exp: New test. * gcc.dg/driver/a.c: New file. * gcc.dg/driver/b.c: New file. * gcc.dg/driver/a.c: New file. --- gcc/testsuite/ChangeLog | 7 ++++ gcc/testsuite/gcc.dg/driver/a.c | 6 +++ gcc/testsuite/gcc.dg/driver/b.c | 6 +++ gcc/testsuite/gcc.dg/driver/driver.exp | 77 ++++++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/driver/foo.c | 7 ++++ 5 files changed, 103 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/driver/a.c create mode 100644 gcc/testsuite/gcc.dg/driver/b.c create mode 100644 gcc/testsuite/gcc.dg/driver/driver.exp create mode 100644 gcc/testsuite/gcc.dg/driver/foo.c (limited to 'gcc') diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7f97394..d854181 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2020-05-27 Giuliano Belinassi + + * gcc.dg/driver/driver.exp: New test. + * gcc.dg/driver/a.c: New file. + * gcc.dg/driver/b.c: New file. + * gcc.dg/driver/a.c: New file. + 2020-05-05 Eric Botcazou * gnat.dg/aggr29.adb: New test. diff --git a/gcc/testsuite/gcc.dg/driver/a.c b/gcc/testsuite/gcc.dg/driver/a.c new file mode 100644 index 0000000..c6b8c2e --- /dev/null +++ b/gcc/testsuite/gcc.dg/driver/a.c @@ -0,0 +1,6 @@ +int puts (const char *); + +void a_func (void) +{ + puts ("A test"); +} diff --git a/gcc/testsuite/gcc.dg/driver/b.c b/gcc/testsuite/gcc.dg/driver/b.c new file mode 100644 index 0000000..76a2cba --- /dev/null +++ b/gcc/testsuite/gcc.dg/driver/b.c @@ -0,0 +1,6 @@ +int puts (const char *); + +void a_func (void) +{ + puts ("Another test"); +} diff --git a/gcc/testsuite/gcc.dg/driver/driver.exp b/gcc/testsuite/gcc.dg/driver/driver.exp new file mode 100644 index 0000000..915cbed --- /dev/null +++ b/gcc/testsuite/gcc.dg/driver/driver.exp @@ -0,0 +1,77 @@ +# Copyright (C) 2008-2020 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib gcc-dg.exp + +proc check-for-errors { test input } { + if { [string equal "$input" ""] } then { + pass "$test: std out" + } else { + fail "$test: std out\n$input" + } +} + +if ![check_effective_target_pthread] { + return +} + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +# Initialize `dg'. +dg-init + + +# Test multi-input compilation +check-for-errors "Multi-input Compilation" \ + [gcc_target_compile "$srcdir/$subdir/a.c $srcdir/$subdir/b.c -c" "" none ""] + +# Compile file and generate an assembler and object file +check-for-errors "Object Generation" \ + [gcc_target_compile "$srcdir/$subdir/a.c -c" "a.o" none ""] +check-for-errors "Object Generation" \ + [gcc_target_compile "$srcdir/$subdir/b.c -c" "a.o" none ""] +check-for-errors "Asembler Generation" \ + [gcc_target_compile "$srcdir/$subdir/a.c -S" "a.S" none ""] +check-for-errors "Asembler Generation" \ + [gcc_target_compile "$srcdir/$subdir/b.c -S" "b.S" none ""] + +# Test object file passthrough +check-for-errors "Object file passthrough" \ + [gcc_target_compile "$srcdir/$subdir/foo.c a.o" "a.exe" none ""] + + +# Test compilation when assembler is provided +check-for-errors "Assembler with Macros" \ + [gcc_target_compile "a.S -c" "a.o" none ""] + +# Clean temporary generated files. +set temp_files {"a.o" "a.S" "b.o" "b.S"} + +foreach f $temp_files { + if { [file exists $f] } { + file delete $f + } +} + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.dg/driver/foo.c b/gcc/testsuite/gcc.dg/driver/foo.c new file mode 100644 index 0000000..a18fd2a --- /dev/null +++ b/gcc/testsuite/gcc.dg/driver/foo.c @@ -0,0 +1,7 @@ +void a_func (void); + +int main() +{ + a_func (); + return 0; +} -- cgit v1.1