From c40d3c4b02ba66dbc99ad7fd01813e42f1b99c6a Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 1 Jul 2010 17:24:35 +0000 Subject: 2010-07-01 Vinu Rajashekhar PR 1597/cpukit * psx13/psx13.scn, psx13/test.c, psxstat/psxstat.scn, psxstat/test.c: Add lchown() and utimes(). --- testsuites/psxtests/psx13/test.c | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'testsuites/psxtests/psx13/test.c') diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index 3a4b9fe809..0f37b584b3 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -14,6 +14,7 @@ * pipe - test implemented * umask - test implemented * utime - test implemented + * utimes - test implemented * * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). @@ -44,6 +45,7 @@ int Dup2Test(void); int FDataSyncTest(void); int UMaskTest(void); int UTimeTest(void); +int UTimesTest(void); int PipeTest(void); int PipeTestNull(void); int PathConfTest(void); @@ -426,6 +428,66 @@ int UTimeTest (void) return (retval); } +/* --------------------------------------------------------------- + * UTimesTest function + * + * Hits the utimes code. Does NOT test the functionality of the underlying utime + * entry in the IMFS op table. + * + * arguments: none + * assumptions: utimes function available. + * actions: set utimes for an invalid filename. + * set utimes for a valid filename. + * + * returns: TRUE if time on valid file is set correctly and utimes failed on + * an invalid filename. + * FALSE otherwise. + * + * --------------------------------------------------------------- + */ + +int UTimesTest (void) +{ + int error = 0, retval = FALSE; + struct timeval time[2]; + struct stat fstat; + + /* First, an invalid filename. */ + error = utimes("!This is an =invalid p@thname!!! :)", NULL); + + if (error == -1) + retval = TRUE; + else + retval = FALSE; + + /* Now, the success test. */ + if (retval == TRUE) { + + time[0].tv_sec = 12345; + time[1].tv_sec = 54321; + + error = utimes("testfile1.tst", &time); + + if (error == 0) { + + /* But, did it set the time? */ + stat ("testfile1.tst", &fstat); + + if ((fstat.st_atime == 12345) && (fstat.st_mtime == 54321 )) + retval = TRUE; + else + retval = FALSE; + } + + else + retval = FALSE; + } + + /* assert (retval == TRUE);*/ + + return (retval); +} + /* --------------------------------------------------------------- * PipeTest function * @@ -663,6 +725,12 @@ int main( else printf ("Failed!!!\n"); + printf ("Testing utimes().......... "); + if (UTimesTest() == TRUE) + printf ("Success.\n"); + else + printf ("Failed!!!\n"); + printf ("Testing pipe()........... "); if (PipeTest() == TRUE) printf ("Success.\n"); -- cgit v1.2.3