diff options
author | Flavio Cruz <flaviocruz@gmail.com> | 2016-04-18 19:48:50 -0400 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2016-04-19 12:04:46 +0200 |
commit | 36457093278a06752c44c10bb98e4b1eeab3f792 (patch) | |
tree | c2e25ebdc3d3832c1b76eadac88c88db9c4d74c0 /tests/good | |
parent | 6dfd373070a059f3d79c663b6fb98bd17b2321d6 (diff) | |
download | mig-36457093278a06752c44c10bb98e4b1eeab3f792.tar.gz mig-36457093278a06752c44c10bb98e4b1eeab3f792.tar.bz2 mig-36457093278a06752c44c10bb98e4b1eeab3f792.zip |
Simple testsuite for MIG.
This includes a set of valid and invalid definition files that MIG will
try to process. For valid definitions, GCC will compile the stubs to
check if valid C code was generated.
* configure.ac: Add new test Makefiles.
* Makefile.am: Add SUBDIRS.
* tests/Makeconf.am: Automake definitions shared by all test
subdirectories.
* tests/test_lib.sh: Library of functions shared by all test drivers.
* tests/good/run_good_test.sh: Script to run valid definition files.
* tests/good/Makefile.am: New file.
* tests/bad/Makefile.am: New file.
* tests/generate-only/Makefile.am: New file.
* tests/bad/run_bad_test.sh: Script to run invalid definition files.
* tests/generate-only/run_generate_only.sh: Script to run valid
definition files that should be generated only.
* tests/includes/*.h: Test header files that are included by test stubs.
* tests/good/*.defs: Valid definition files where
generated stubs can be compiled.
* tests/generate_only/*.defs: Valid definition files that can be
generated but no compilation should be attempted.
* tests/bad/*.defs: Definition files with problems that should be
detected by MIG.
Diffstat (limited to 'tests/good')
-rw-r--r-- | tests/good/Makefile.am | 23 | ||||
-rw-r--r-- | tests/good/case.defs | 27 | ||||
-rw-r--r-- | tests/good/complex-types.defs | 40 | ||||
-rw-r--r-- | tests/good/directions.defs | 62 | ||||
-rw-r--r-- | tests/good/import.defs | 24 | ||||
-rw-r--r-- | tests/good/routine.defs | 35 | ||||
-rwxr-xr-x | tests/good/run_good_test.sh | 32 | ||||
-rw-r--r-- | tests/good/types.defs | 74 | ||||
-rw-r--r-- | tests/good/waittime.defs | 36 |
9 files changed, 353 insertions, 0 deletions
diff --git a/tests/good/Makefile.am b/tests/good/Makefile.am new file mode 100644 index 0000000..adc5b45 --- /dev/null +++ b/tests/good/Makefile.am @@ -0,0 +1,23 @@ +# Copyright (C) 2016 Free Software Foundation, Inc. +# +# This file is part of GNU MIG. +# +# GNU MIG 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 2, or (at +# your option) any later version. +# +# GNU MIG 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 GNU MIG. If not, see <http://www.gnu.org/licenses/>. +# + +TESTS = case.defs complex-types.defs directions.defs import.defs \ + routine.defs types.defs waittime.defs +DEFS_LOG_COMPILER = sh ./$(srcdir)/run_good_test.sh + +include $(srcdir)/../Makeconf.am diff --git a/tests/good/case.defs b/tests/good/case.defs new file mode 100644 index 0000000..25ba510 --- /dev/null +++ b/tests/good/case.defs @@ -0,0 +1,27 @@ +/* + Copyright (C) 2016 Free Software Foundation, Inc. + + This file is part of GNU MIG. + + GNU MIG 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 2, or (at + your option) any later version. + + GNU MIG 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 GNU MIG. If not, see <http://www.gnu.org/licenses/>. */ + +/* Tests some keywords with different casing. */ +SUBSYSTEM myroutine 100; + +TyPe int = MACH_MSG_TYPE_INTEGER_64; +typE mach_port_t = MACH_MSG_TYPE_COPY_SEND; + +RouTine factorial(port : mach_port_t; + n : int; + out result : int); diff --git a/tests/good/complex-types.defs b/tests/good/complex-types.defs new file mode 100644 index 0000000..a10fc21 --- /dev/null +++ b/tests/good/complex-types.defs @@ -0,0 +1,40 @@ +/* + Copyright (C) 2016 Free Software Foundation, Inc. + + This file is part of GNU MIG. + + GNU MIG 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 2, or (at + your option) any later version. + + GNU MIG 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 GNU MIG. If not, see <http://www.gnu.org/licenses/>. */ + +/* Tests complex types such as pointers, arrays and structs. */ +subsystem types 0; + +import <stdint.h>; +import "types.h"; + +type char = MACH_MSG_TYPE_BYTE; +type intptr_t = ^char; +type pointer_t = ^array[] of MACH_MSG_TYPE_BYTE + ctype: vm_offset_t; + +type mach_port_t = MACH_MSG_TYPE_COPY_SEND; +type mach_port_array_t = array[] of mach_port_t; +type char_struct_t = struct[4] of char; +type string_t = array[256] of char; + +routine callcomplex(port : mach_port_t; + p : pointer_t; + q : intptr_t; + str : char_struct_t; + strt : string_t; + out vec : mach_port_array_t); diff --git a/tests/good/directions.defs b/tests/good/directions.defs new file mode 100644 index 0000000..37c5767 --- /dev/null +++ b/tests/good/directions.defs @@ -0,0 +1,62 @@ +/* + Copyright (C) 2016 Free Software Foundation, Inc. + + This file is part of GNU MIG. + + GNU MIG 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 2, or (at + your option) any later version. + + GNU MIG 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 GNU MIG. If not, see <http://www.gnu.org/licenses/>. */ + +/* Tests arguments with different directions. */ +subsystem directions 100; + +type char = MACH_MSG_TYPE_BYTE; +type int = MACH_MSG_TYPE_INTEGER_32; + +type mach_port_t = MACH_MSG_TYPE_COPY_SEND; +type mach_port_array_t = array[] of mach_port_t; + +routine callinout(port : mach_port_t; + in n : int; + out result : int); + +routine multiplein(port : mach_port_t; + in n1 : int; + in n2 : int; + in n3 : int; + out result : int); + +routine multipleout(port : mach_port_t; + in n : int; + out result1 : int; + out result2 : int; + out result3 : int); + +routine serverreplyport(port : mach_port_t; + sreplyport server_port : mach_port_t; + in n : int; + out result : int); + +routine userreplyport(port : mach_port_t; + ureplyport user_port : mach_port_t; + out result : int); + +routine myrequestport(requestport port : mach_port_t; + new_port : mach_port_t); + +routine singleinandout(port : mach_port_t; + inout n : int); + +routine multipleinandout(port : mach_port_t; + inout n1 : int; + inout n2 : int; + out result : int); diff --git a/tests/good/import.defs b/tests/good/import.defs new file mode 100644 index 0000000..e90558a --- /dev/null +++ b/tests/good/import.defs @@ -0,0 +1,24 @@ +/* + Copyright (C) 2016 Free Software Foundation, Inc. + + This file is part of GNU MIG. + + GNU MIG 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 2, or (at + your option) any later version. + + GNU MIG 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 GNU MIG. If not, see <http://www.gnu.org/licenses/>. */ + +/* Tests the different import statements. */ +subsystem myimport 100; + +simport "server.h"; +uimport "user.h"; +import "all.h"; diff --git a/tests/good/routine.defs b/tests/good/routine.defs new file mode 100644 index 0000000..a108bc3 --- /dev/null +++ b/tests/good/routine.defs @@ -0,0 +1,35 @@ +/* + Copyright (C) 2016 Free Software Foundation, Inc. + + This file is part of GNU MIG. + + GNU MIG 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 2, or (at + your option) any later version. + + GNU MIG 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 GNU MIG. If not, see <http://www.gnu.org/licenses/>. */ + +/* Tests simple routines. */ +subsystem myroutine 100; + +import <stdint.h>; +#include "base_types.defs" + +routine factorial(port : mach_port_t; + n : int64_t; + out result : int64_t); + +routine timedoutfactorial(port : mach_port_t; + n : int64_t; + waittime timeout : int32_t; + out result : int64_t); + +simpleroutine simple_factorial(port : mach_port_t; + n : int64_t); diff --git a/tests/good/run_good_test.sh b/tests/good/run_good_test.sh new file mode 100755 index 0000000..01c2049 --- /dev/null +++ b/tests/good/run_good_test.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Copyright (C) 2016 Free Software Foundation, Inc. +# +# This file is part of GNU MIG. +# +# GNU MIG 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 2, or (at +# your option) any later version. +# +# GNU MIG 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 GNU MIG. If not, see <http://www.gnu.org/licenses/>. +# + +. $SRCDIR/tests/test_lib.sh + +file=$1 +module="$(basename $file .defs)" +if ! run_mig $file $module; then + failure "Could not generate stubs for $module" + exit 1 +fi +if ! test_module $module; then + failure "Could not compile stubs for $module" + exit 1 +fi diff --git a/tests/good/types.defs b/tests/good/types.defs new file mode 100644 index 0000000..a27c191 --- /dev/null +++ b/tests/good/types.defs @@ -0,0 +1,74 @@ +/* + Copyright (C) 2016 Free Software Foundation, Inc. + + This file is part of GNU MIG. + + GNU MIG 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 2, or (at + your option) any later version. + + GNU MIG 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 GNU MIG. If not, see <http://www.gnu.org/licenses/>. */ + +/* Tests simple types and port types. */ +subsystem types 0; + +import <stdint.h>; +import "types.h"; +#include "../base_types.defs" + +type char = MACH_MSG_TYPE_CHAR; +type int16_t = MACH_MSG_TYPE_INTEGER_16; +type boolean_t = MACH_MSG_TYPE_BOOLEAN; +type uint16_t = MACH_MSG_TYPE_INTEGER_16; +type uint32_t = MACH_MSG_TYPE_INTEGER_32; +type uint64_t = MACH_MSG_TYPE_INTEGER_64; +type move_receive_t = MACH_MSG_TYPE_MOVE_RECEIVE + ctype: mach_port_t; +type copy_send_t = MACH_MSG_TYPE_COPY_SEND + ctype: mach_port_t; +type move_send_t = MACH_MSG_TYPE_MOVE_SEND + ctype: mach_port_t; +type move_send_once_t = MACH_MSG_TYPE_MOVE_SEND_ONCE + ctype : mach_port_t; +type port_send_t = MACH_MSG_TYPE_PORT_SEND + ctype : mach_port_t; + +type another_int = int + cusertype: int32_t + cservertype: uint32_t; + +type trans_int = int + ctype: int + intran: int8_t int_to_int8(int) + outtran: int int8_to_int(int8_t); + +routine alltypes(port : mach_port_t; + c : char; s : int16_t; i : int; + i32 : int32_t; i64 : int64_t; bool : boolean_t; + ui16 : uint16_t; ui32 : uint32_t; ui64 : uint64_t); + +/* This should fail. */ +/* routine receive(port : move_receive_t); */ + +routine movereceive(port : mach_port_t; copy : move_receive_t); + +routine movesend(port : mach_port_t; copy : move_send_t); + +routine movesendonce(port : mach_port_t; move : move_send_once_t); + +routine copysend(port : mach_port_t; receive : copy_send_t); + +routine portsend(port : mach_port_t; send : port_send_t); + +routine another(port : mach_port_t; + n : another_int); + +routine dotrans(port : mach_port_t; + inout n : trans_int); diff --git a/tests/good/waittime.defs b/tests/good/waittime.defs new file mode 100644 index 0000000..0de7aef --- /dev/null +++ b/tests/good/waittime.defs @@ -0,0 +1,36 @@ +/* + Copyright (C) 2016 Free Software Foundation, Inc. + + This file is part of GNU MIG. + + GNU MIG 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 2, or (at + your option) any later version. + + GNU MIG 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 GNU MIG. If not, see <http://www.gnu.org/licenses/>. */ + +/* Tests the wait time directive. */ +subsystem timeout 100; + +import <stdint.h>; +#include "../base_types.defs" + +/* All routines will have this timeout. */ +waittime 2; + +routine factorial(port : mach_port_t; + n : int64_t; + out result : int64_t); + +/* This routine has a waittime argument. */ +routine factorial_waittime(port : mach_port_t; + waittime wait : int32_t; + n : int64_t; + out result : int64_t); |