From 85c55972689fbb68bfa211a74a575471f877fcd6 Mon Sep 17 00:00:00 2001 From: neil Date: Mon, 20 Jul 2015 23:51:46 +0000 Subject: [PATCH] Return non-zero if an error occurs. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@50968 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- test/dos/readitemloop.c | 7 ++++--- test/dos/seektest.c | 4 ++-- test/dos/setenv.c | 53 ++++++++++++++++++++++++++++++++++++++++--------- test/dos/strtodate.c | 5 ++++- 4 files changed, 54 insertions(+), 15 deletions(-) diff --git a/test/dos/readitemloop.c b/test/dos/readitemloop.c index e6504a3746..5d1f7a17b3 100644 --- a/test/dos/readitemloop.c +++ b/test/dos/readitemloop.c @@ -10,7 +10,7 @@ int __nocommandline = 1; -/* No newline in the end!!! Important!!! */ +/* No newline in the end! Important! */ static char text[] = "WORD1 WORD2 WORD3"; static char buf[256]; @@ -18,7 +18,7 @@ int main(void) { struct CSource cs; int i; - LONG res; + LONG result = RETURN_OK, res; cs.CS_Buffer = text; cs.CS_Length = sizeof(text) - 1; @@ -34,10 +34,11 @@ int main(void) if (i == 10) { Printf("ERROR: Unrecoverable loop detected!\n"); + result = RETURN_ERROR; break; } } while (res != ITEM_NOTHING); - return 0; + return result; } diff --git a/test/dos/seektest.c b/test/dos/seektest.c index fd4c790eeb..0f576c0c3f 100644 --- a/test/dos/seektest.c +++ b/test/dos/seektest.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2014, The AROS Development Team. All rights reserved. + Copyright © 1995-2015, The AROS Development Team. All rights reserved. $Id$ */ @@ -34,6 +34,6 @@ int main() free(buffer); Close(fh); - return 0; + return filepos == -1 ? RETURN_ERROR : RETURN_OK; } diff --git a/test/dos/setenv.c b/test/dos/setenv.c index f4ff8df667..2f3becf82e 100644 --- a/test/dos/setenv.c +++ b/test/dos/setenv.c @@ -7,70 +7,105 @@ #include #include -static void testvalue(CONST_STRPTR var, STRPTR expval, ULONG explen, +static LONG testvalue(CONST_STRPTR var, STRPTR expval, ULONG explen, BOOL expnull, LONG cnt) { TEXT buffer[10]; - LONG len; + LONG len, failed = 0; struct LocalVar *lv; if ((len = GetVar(var, buffer, sizeof(buffer), 0)) < 0) + { printf("test %d ERROR getvar %d\n", (int)cnt, (int)len); + failed++; + } else printf("test %d getvar '%s'\n", (int)cnt, buffer); + if ((lv = FindVar(var, 0)) == NULL) + { printf("test %d ERROR findvar\n", (int)cnt); + failed++; + } else printf("test %d findvar lv_Value=%p, lv_Len=%d\n", (int)cnt, lv->lv_Value, (int)lv->lv_Len); + if (lv->lv_Len != explen) + { printf("test %d ERROR lv_Len, expected %d, found %d\n", (int)cnt, (int)explen, (int)lv->lv_Len); + failed++; + } + if (expnull && lv->lv_Value != NULL) + { printf("test %d ERROR lv_Value expected NULL, found %p\n", (int)cnt, lv->lv_Value); + failed++; + } if (!expnull && lv->lv_Value == NULL) + { printf("test %d ERROR lv_Value expected not NULL, found %p\n", (int)cnt, lv->lv_Value); + failed++; + } + + return failed; } int main(void) { CONST_STRPTR var = "abc"; STRPTR val = "cde"; - LONG cnt = 1; + LONG cnt = 1, failed = 0; /* Behavior validated with OS3.x */ printf("test %d setvar '%s'\n", (int)cnt, val); if (SetVar(var, val, strlen(val), 0) == DOSFALSE) + { printf("error setvar\n"); - testvalue(var, val, 3, FALSE, cnt++); + failed++; + } + failed += testvalue(var, val, 3, FALSE, cnt++); val = ""; printf("test %d setvar '%s'\n", (int)cnt, val); if (SetVar(var, val, strlen(val), 0) == DOSFALSE) + { printf("error setvar\n"); - testvalue(var, val, 0, TRUE, cnt++); + failed++; + } + failed += testvalue(var, val, 0, TRUE, cnt++); val = "abcd"; printf("test %d setvar '%s'\n", (int)cnt, val); if (SetVar(var, val, strlen(val), 0) == DOSFALSE) + { printf("error setvar\n"); - testvalue(var, val, 4, FALSE, cnt++); + failed++; + } + failed += testvalue(var, val, 4, FALSE, cnt++); val = ""; printf("test %d setvar '%s'\n", (int)cnt, val); if (SetVar(var, val, strlen(val), 0) == DOSFALSE) + { printf("error setvar\n"); - testvalue(var, val, 0, TRUE, cnt++); + failed++; + } + failed += testvalue(var, val, 0, TRUE, cnt++); val = ""; printf("test %d setvar '%s'\n", (int)cnt, val); if (SetVar(var, val, strlen(val), 0) == DOSFALSE) + { printf("error setvar\n"); - testvalue(var, val, 0, TRUE, cnt++); + failed++; + } + failed += testvalue(var, val, 0, TRUE, cnt++); - return 0; + return failed == 0 ? RETURN_OK : RETURN_ERROR; } diff --git a/test/dos/strtodate.c b/test/dos/strtodate.c index dec844933e..b8daeb852a 100644 --- a/test/dos/strtodate.c +++ b/test/dos/strtodate.c @@ -17,6 +17,8 @@ LONG days = 0; int main(void) { + LONG result = RETURN_OK; + do { dt.dat_Stamp.ds_Days = days; @@ -35,6 +37,7 @@ int main(void) printf("Bad results for date \"%s\" (day #%ld). " "StrToDate thought it was day #%ld\n", s, (long)days, (long)dt.dat_Stamp.ds_Days); + result = RETURN_ERROR; } days++; @@ -43,5 +46,5 @@ int main(void) while (!CheckSignal(SIGBREAKF_CTRL_C) && (days < 36525)); /* 2078-01-01: same as 1978 in FORMAT_DOS */ - return 0; + return result; } -- 2.11.4.GIT