/[gxemul]/trunk/tests/do_tests.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/tests/do_tests.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (hide annotations)
Mon Oct 8 16:18:27 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 6267 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.815 2005/06/27 23:04:35 debug Exp $
20050617	Experimenting some more with netbooting OpenBSD/sgi. Adding
		a hack which allows emulated ethernet networks to be
		distributed across multiple emulator processes.
20050618	Minor updates (documentation, dummy YAMON emulation, etc).
20050620	strcpy/strcat -> strlcpy/strlcat updates.
		Some more progress on evbmips (Malta).
20050621	Adding a section to doc/configfiles.html about ethernet
		emulation across multiple hosts.
		Beginning the work on the ARM translation engine (using the
		dynamic-but-not-binary translation method).
		Fixing a bintrans bug: 0x9fc00000 should always be treated as
		PROM area, just as 0xbfc00000 is.
		Minor progress on Malta emulation (the PCI-ISA bus).
20050622	NetBSD/evbmips can now be installed (using another emulated
		machine) and run (including userland and so on). :-)
		Spliting up the bintrans haddr_entry field into two (one for
		read, one for write). Probably not much of a speed increase,
		though.
		Updating some NetBSD 2.0 -> 2.0.2 in the documentation.
20050623	Minor updates (documentation, the TODO file, etc).
		gzipped kernels are now always automagically gunzipped when
		loaded.
20050624	Adding a dummy Playstation Portable (PSP) mode, just barely
		enough to run Hello World (in weird colors :-).
		Removing the -b command line option; old bintrans is enabled
		by default instead. It makes more sense.
		Trying to finally fix the non-working performance measurement
		thing (instr/second etc).
20050625	Continuing on the essential basics for ARM emulation. Two
		instructions seem to work, a branch and a simple "mov". (The
		mov arguments are not correct yet.) Performance is definitely
		reasonable.
		Various other minor updates.
		Adding the ARM "bl" instruction.
		Adding support for combining multiple ARM instructions into one
		function call. ("mov" + "mov" is the only one implemented so
		far, but it seems to work.)
		Cleaning up some IP32 interrupt things (crime/mace); disabling
		the PS/2 keyboard controller on IP32, so that NetBSD/sgimips
		boots into userland again.
20050626	Finally! NetBSD/sgimips netboots. Adding instructions to
		doc/guestoses.html on how to set up an nfs server etc.
		Various other minor fixes.
		Playstation Portable ".pbp" files can now be used directly.
		(The ELF part of the .pbp is extracted transparently.)
		Converting some sprintf -> snprintf.
		Adding some more instructions to the ARM disassembler.
20050627	More ARM updates. Adding some simple ldr(b), str(b),
		cmps, and conditional branch instructions, enough to run
		a simple Hello World program.
		All ARM instructions are now inlined/generated for all possible
		condition codes.
		Adding add and sub, and more load/store instructions.
		Removing dummy files: cpu_alpha.c, cpu_hppa.c, and cpu_sparc.c.
		Some minor documentation updates; preparing for a 0.3.4
		release. Updating some URLs.

==============  RELEASE 0.3.4  ==============


1 dpavlin 2 /*
2     * Copyright (C) 2004-2005 Anders Gavare. All rights reserved.
3     *
4     * Redistribution and use in source and binary forms, with or without
5     * modification, are permitted provided that the following conditions are met:
6     *
7     * 1. Redistributions of source code must retain the above copyright
8     * notice, this list of conditions and the following disclaimer.
9     * 2. Redistributions in binary form must reproduce the above copyright
10     * notice, this list of conditions and the following disclaimer in the
11     * documentation and/or other materials provided with the distribution.
12     * 3. The name of the author may not be used to endorse or promote products
13     * derived from this software without specific prior written permission.
14     *
15     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16     * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18     * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19     * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21     * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24     * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25     * SUCH DAMAGE.
26     *
27     *
28 dpavlin 10 * $Id: do_tests.c,v 1.12 2005/06/26 11:36:30 debug Exp $
29 dpavlin 2 *
30     * This program assembles, links, and runs all regression tests.
31     */
32    
33     #include <dirent.h>
34     #include <stdio.h>
35     #include <stdlib.h>
36     #include <string.h>
37     #include <sys/types.h>
38     #include <sys/stat.h>
39    
40    
41     static char *progname;
42     static char *invoke_cc, *invoke_as, *invoke_ld, *invoke_gxemul;
43    
44 dpavlin 10 #define MAX_WAYS 1
45     static char *way_args[MAX_WAYS] = { "-E testmips" };
46 dpavlin 2
47    
48     /*
49     * usage():
50     */
51     void usage(void)
52     {
53     fprintf(stderr, "usage: %s how_to_invoke_cc how_to_invoke_as "
54     "how_to_invoke_ld\n", progname);
55     fprintf(stderr, "For example, when using GCC compiled for the "
56     "mips64-unknown-elf target:\n");
57     fprintf(stderr, " %s \"mips64-unknown-elf-gcc -g -O3 -fno-builtin "
58     "-fschedule-insns -mips4 -mabi=64\"\n"
59     " \"mips64-unknown-elf-as\"\n"
60     " \"mips64-unknown-elf-ld -Ttext 0xffffffff80030000 -e "
61     "main --oformat=elf64-bigmips\"\n", progname);
62     }
63    
64    
65     /*
66     * do_tests():
67     *
68     * Returns 0 if ALL tests passed.
69     * Returns non-zero otherwise.
70     */
71     int do_tests(void)
72     {
73     int test_nr = 0, way = 0;
74     int tests_passed = 0, tests_failed = 0;
75     DIR *dirp;
76     char *args;
77     char fname[200], oname[200], ename[200], gname[200];
78     struct stat st;
79     struct dirent *dp;
80     int res;
81    
82     dirp = opendir(".");
83     printf("\nStarting tests:\n");
84    
85     for (;;) {
86     if (way == 0) {
87     dp = readdir(dirp);
88     if (dp == NULL)
89     break;
90    
91     if (strncmp(dp->d_name, "test_", 5) != 0 ||
92     strlen(dp->d_name) < 6 ||
93     strcmp(dp->d_name + strlen(dp->d_name) - 2, ".S")
94     != 0)
95     continue;
96    
97     snprintf(fname, sizeof(fname), dp->d_name);
98    
99 dpavlin 10 strlcpy(oname, fname, sizeof(oname));
100     strlcpy(ename, oname, sizeof(ename));
101     strlcpy(gname, oname, sizeof(gname));
102 dpavlin 2
103 dpavlin 10 /* Remove the 'S': */
104     oname[strlen(oname)-1] = '\0';
105     ename[strlen(ename)-1] = '\0';
106     gname[strlen(gname)-1] = '\0';
107    
108     strlcat(oname, "o", sizeof(oname));
109     strlcat(ename, "out", sizeof(ename));
110     /* ename = MIPS executable */
111     strlcat(gname, "good", sizeof(gname));
112 dpavlin 2 }
113    
114     args = way_args[way];
115     printf(" %s (%s)\n", fname, args);
116    
117     res = stat(fname, &st);
118     if (res == 0) {
119     char s[10000];
120     /* File exists, let's assemble it: */
121 dpavlin 10 snprintf(s, sizeof(s), "%s %s -o %s", invoke_as,
122     fname, oname);
123 dpavlin 2 res = system(s);
124     if (res != 0) {
125     printf("%05i: ERROR when invoking assembler, "
126     "error code %i\n", test_nr, res);
127     tests_failed ++;
128     } else {
129 dpavlin 10 snprintf(s, sizeof(s),
130     "%s test_common.o %s -o %s",
131 dpavlin 2 invoke_ld, oname, ename);
132     res = system(s);
133     if (res != 0) {
134     printf("%05i: ERROR when invoking "
135     "linker, error code %i\n",
136     test_nr, res);
137     tests_failed ++;
138     } else {
139     char *t = tmpnam(NULL);
140     /* printf("t = %s\n", t); */
141 dpavlin 10 snprintf(s, sizeof(s),
142     "%s -q %s %s > %s",
143 dpavlin 2 invoke_gxemul, args, ename, t);
144     res = system(s);
145     if (res != 0) {
146     printf("%05i: ERROR when "
147     "invoking gxemul, error"
148     " code %i\n", test_nr, res);
149     tests_failed ++;
150     } else {
151     /* Compare the output to a
152     known good test result: */
153 dpavlin 10 snprintf(s, sizeof(s),
154     "cmp -s %s %s", gname, t);
155 dpavlin 2 res = system(s);
156     if (res != 0) {
157     printf("%05i: ERROR "
158     "when comparing cur"
159     "rent output to kno"
160     "wn good output\n",
161     test_nr);
162 dpavlin 10 snprintf(s, sizeof(s),
163     "cat %s\n", gname);
164 dpavlin 2 printf("%s\n", s);
165     system(s);
166 dpavlin 10 snprintf(s, sizeof(s),
167     "cat %s\n", t);
168 dpavlin 2 printf("%s\n", s);
169     system(s);
170     tests_failed ++;
171     } else {
172     tests_passed ++;
173     }
174     remove(t);
175     }
176     }
177     }
178     } else
179     break;
180    
181     way = (way + 1) % MAX_WAYS;
182    
183     test_nr ++;
184     }
185    
186     closedir(dirp);
187    
188     printf("\nDone. (%i tests done)\n", test_nr);
189     printf(" PASS: %6i\n", tests_passed);
190     printf(" FAIL: %6i\n", tests_failed);
191    
192     if (tests_failed != 0) {
193     printf("\n*** ONE OR MORE TESTS FAILED!!! ***\n\n");
194     return 1;
195     } else if (tests_failed + tests_passed != test_nr) {
196     printf("\n*** INTERNAL ERROR IN do_tests.c ***\n\n");
197     return 1;
198     } else {
199     printf("\n\n----------------\n\n"
200     " All tests OK\n\n----------------\n\n");
201     }
202    
203     return 0;
204     }
205    
206    
207     /*
208     * main():
209     */
210     int main(int argc, char *argv[])
211     {
212     char s[10000];
213    
214     progname = argv[0];
215    
216     if (argc != 5) {
217     usage();
218     exit(1);
219     }
220    
221     invoke_cc = argv[1];
222     invoke_as = argv[2];
223     invoke_ld = argv[3];
224     invoke_gxemul = argv[4];
225    
226     /* fprintf(stderr, "%s: debug:\n"
227     " invoke_cc = '%s'\n"
228     " invoke_as = '%s'\n"
229     " invoke_ld = '%s'\n"
230     " invoke_gxemul = '%s'\n",
231     progname, invoke_cc, invoke_as, invoke_ld, invoke_gxemul); */
232    
233     return do_tests();
234     }
235    

  ViewVC Help
Powered by ViewVC 1.1.26