--- trunk/tests/do_tests.c 2007/10/08 16:18:22 9 +++ trunk/tests/do_tests.c 2007/10/08 16:18:27 10 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: do_tests.c,v 1.8 2005/03/05 12:05:31 debug Exp $ + * $Id: do_tests.c,v 1.12 2005/06/26 11:36:30 debug Exp $ * * This program assembles, links, and runs all regression tests. */ @@ -41,8 +41,8 @@ static char *progname; static char *invoke_cc, *invoke_as, *invoke_ld, *invoke_gxemul; -#define MAX_WAYS 2 -static char *way_args[MAX_WAYS] = { "-E testmips", "-E testmips -b" }; +#define MAX_WAYS 1 +static char *way_args[MAX_WAYS] = { "-E testmips" }; /* @@ -96,13 +96,19 @@ snprintf(fname, sizeof(fname), dp->d_name); - strcpy(oname, fname); oname[strlen(oname)-1] = '\0'; - strcpy(ename, oname); - strcpy(gname, oname); - - strcat(oname, "o"); - strcat(ename, "out"); /* MIPS executable */ - strcat(gname, "good"); + strlcpy(oname, fname, sizeof(oname)); + strlcpy(ename, oname, sizeof(ename)); + strlcpy(gname, oname, sizeof(gname)); + + /* Remove the 'S': */ + oname[strlen(oname)-1] = '\0'; + ename[strlen(ename)-1] = '\0'; + gname[strlen(gname)-1] = '\0'; + + strlcat(oname, "o", sizeof(oname)); + strlcat(ename, "out", sizeof(ename)); + /* ename = MIPS executable */ + strlcat(gname, "good", sizeof(gname)); } args = way_args[way]; @@ -112,14 +118,16 @@ if (res == 0) { char s[10000]; /* File exists, let's assemble it: */ - sprintf(s, "%s %s -o %s", invoke_as, fname, oname); + snprintf(s, sizeof(s), "%s %s -o %s", invoke_as, + fname, oname); res = system(s); if (res != 0) { printf("%05i: ERROR when invoking assembler, " "error code %i\n", test_nr, res); tests_failed ++; } else { - sprintf(s, "%s test_common.o %s -o %s", + snprintf(s, sizeof(s), + "%s test_common.o %s -o %s", invoke_ld, oname, ename); res = system(s); if (res != 0) { @@ -130,7 +138,8 @@ } else { char *t = tmpnam(NULL); /* printf("t = %s\n", t); */ - sprintf(s, "%s -q %s %s > %s", + snprintf(s, sizeof(s), + "%s -q %s %s > %s", invoke_gxemul, args, ename, t); res = system(s); if (res != 0) { @@ -141,8 +150,8 @@ } else { /* Compare the output to a known good test result: */ - sprintf(s, "cmp -s %s %s", - gname, t); + snprintf(s, sizeof(s), + "cmp -s %s %s", gname, t); res = system(s); if (res != 0) { printf("%05i: ERROR " @@ -150,12 +159,12 @@ "rent output to kno" "wn good output\n", test_nr); - sprintf(s, "cat %s\n", - gname); + snprintf(s, sizeof(s), + "cat %s\n", gname); printf("%s\n", s); system(s); - sprintf(s, "cat %s\n", - t); + snprintf(s, sizeof(s), + "cat %s\n", t); printf("%s\n", s); system(s); tests_failed ++;