RE: [PATCH v6 4/5] psx13: Added tests for utimensat() and futimens()
-Original Message- From: Gedare Bloom Sent: Tuesday, May 18, 2021 3:15 PM To: Ryan Long Cc: devel@rtems.org Subject: Re: [PATCH v6 4/5] psx13: Added tests for utimensat() and futimens() On Tue, May 18, 2021 at 2:03 PM Ryan Long wrote: > > Improved tests for utime() and utimes() and update license. > > Close #4399 > --- > testsuites/psxtests/psx13/main.c | 5 +- > testsuites/psxtests/psx13/test.c | 499 > +-- > 2 files changed, 481 insertions(+), 23 deletions(-) > > diff --git a/testsuites/psxtests/psx13/main.c > b/testsuites/psxtests/psx13/main.c > index f9e7907..7a560f9 100644 > --- a/testsuites/psxtests/psx13/main.c > +++ b/testsuites/psxtests/psx13/main.c > @@ -1,5 +1,3 @@ > -/* SPDX-License-Identifier: BSD-2-Clause */ > - why this is being removed? [Ryan Long] I don't remember doing this, but I'll make sure it's put back in. > /** > * @file > * > @@ -8,8 +6,7 @@ > */ > > /* > - * COPYRIGHT (c) 1989-2009, 2021. > - * On-Line Applications Research Corporation (OAR). > + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > diff --git a/testsuites/psxtests/psx13/test.c > b/testsuites/psxtests/psx13/test.c > index e98b03a..0754dbc 100644 > --- a/testsuites/psxtests/psx13/test.c > +++ b/testsuites/psxtests/psx13/test.c > @@ -1,4 +1,4 @@ > -/* SPDX-License-Identifier: BSD-2-Clause */ > +/* SPDX-License-Identifier: BSD-2-Clause */ > > /** > * @file > @@ -17,12 +17,13 @@ > * - umask() > * - utime() > * - utimes() > + * - utimensat() > + * - futimens() > * - sync() > */ > > /* > - * COPYRIGHT (c) 1989-2009, 2021. > - * On-Line Applications Research Corporation (OAR). > + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > @@ -52,6 +53,8 @@ > > #include > #include > +#include > +#include > #include > #include > #include > @@ -210,8 +213,7 @@ static void Dup2Test( void ) } > > /** > - * @brief Exercises fdatasync(). Does NOT test the functionality of the > - *underlying fdatasync entry in the IMFS op table. > + * @brief Exercises fdatasync(). > */ > static void FDataSyncTest( void ) > { > @@ -259,60 +261,517 @@ static void UMaskTest( void ) } > > /** > - * @brief Exercises utime(). Does not test the functionality of the > - *underlying utime entry in the IMFS op table. > + * @brief Exercises utime(). > */ > static void UTimeTest( void ) > { >int rv; >struct utimbuf time; > + struct timespec current_time; >struct stat fstat; > > - /* First, an invalid filename. */ > + /* ENOENT test case */ > + > + /* Case: Pass an invalid filename. */ >rv = utime( "!This is an =invalid p@thname!!! :)", NULL ); >rtems_test_assert( rv == -1 ); >rtems_test_assert( errno == ENOENT ); > > - /* Now, the success test. */ > + /* EACCES test case */ > + > + /* Case: Change user ID to someone besides root */ rv = seteuid( 1 > + ); rtems_test_assert( rv == 0 ); > + > + rv = utime( "testfile1.tst", NULL ); rtems_test_assert( rv == -1 > + ); rtems_test_assert( errno == EACCES ); > + > + rv = seteuid( 0 ); > + rtems_test_assert( rv == 0 ); > + > + /* EINVAL test cases */ > + > + /* Case: Invalid access time */ > + time.actime = -1; > + time.modtime = 54321; > + > + rv = utime( "testfile1.tst", ); rtems_test_assert( rv == -1 > + ); rtems_test_assert( errno == EINVAL ); > + > + /* Case: Invalid modified time */ > + time.actime = 12345; > + time.modtime = -1; > + > + rv = utime( "testfile1.tst", ); rtems_test_assert( rv == -1 > + ); rtems_test_assert( errno == EINVAL ); > + > + /* Successful test cases */ > + > + /* Case: Test without times argument */ clock_gettime( > + CLOCK_REALTIME, _time ); > + > + rv = utime( "testfile1.tst", NULL ); rtems_test_assert( rv == 0 ); > + > + rv = stat( "testfile1.tst", ); rtems_test_assert( rv == 0 > + ); rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec > + ); rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec > + ); > + > + /* Case: time is filled with valid values */ >time.actime = 12345; >time.modtime = 54321; > >
Re: [PATCH v6 4/5] psx13: Added tests for utimensat() and futimens()
On Tue, May 18, 2021 at 2:21 PM Joel Sherrill wrote: > > > > On Tue, May 18, 2021 at 3:03 PM Ryan Long wrote: >> >> Improved tests for utime() and utimes() and update license. >> >> Close #4399 >> --- >> testsuites/psxtests/psx13/main.c | 5 +- >> testsuites/psxtests/psx13/test.c | 499 >> +-- >> 2 files changed, 481 insertions(+), 23 deletions(-) >> >> diff --git a/testsuites/psxtests/psx13/main.c >> b/testsuites/psxtests/psx13/main.c >> index f9e7907..7a560f9 100644 >> --- a/testsuites/psxtests/psx13/main.c >> +++ b/testsuites/psxtests/psx13/main.c >> @@ -1,5 +1,3 @@ >> -/* SPDX-License-Identifier: BSD-2-Clause */ >> - > > > Agree with Gedare. This shouldn't have been removed. > > There were some dates changed in the copyrights. > > Check all of the issues against all of the patches. > >> >> /** >> * @file >> * >> @@ -8,8 +6,7 @@ >> */ >> >> /* >> - * COPYRIGHT (c) 1989-2009, 2021. >> - * On-Line Applications Research Corporation (OAR). >> + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). > > > This changes the years which is wrong. > Actually, we only document the first and last year now. >> >> * >> * Redistribution and use in source and binary forms, with or without >> * modification, are permitted provided that the following conditions >> diff --git a/testsuites/psxtests/psx13/test.c >> b/testsuites/psxtests/psx13/test.c >> index e98b03a..0754dbc 100644 >> --- a/testsuites/psxtests/psx13/test.c >> +++ b/testsuites/psxtests/psx13/test.c >> @@ -1,4 +1,4 @@ >> -/* SPDX-License-Identifier: BSD-2-Clause */ >> +/* SPDX-License-Identifier: BSD-2-Clause */ >> >> /** >> * @file >> @@ -17,12 +17,13 @@ >> * - umask() >> * - utime() >> * - utimes() >> + * - utimensat() >> + * - futimens() >> * - sync() >> */ >> >> /* >> - * COPYRIGHT (c) 1989-2009, 2021. >> - * On-Line Applications Research Corporation (OAR). >> + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). > > > Again a year change. >> >> * >> * Redistribution and use in source and binary forms, with or without >> * modification, are permitted provided that the following conditions >> @@ -52,6 +53,8 @@ >> >> #include >> #include >> +#include >> +#include >> #include >> #include >> #include >> @@ -210,8 +213,7 @@ static void Dup2Test( void ) >> } >> >> /** >> - * @brief Exercises fdatasync(). Does NOT test the functionality of the >> - *underlying fdatasync entry in the IMFS op table. >> + * @brief Exercises fdatasync(). >> */ >> static void FDataSyncTest( void ) >> { >> @@ -259,60 +261,517 @@ static void UMaskTest( void ) >> } >> >> /** >> - * @brief Exercises utime(). Does not test the functionality of the >> - *underlying utime entry in the IMFS op table. >> + * @brief Exercises utime(). >> */ >> static void UTimeTest( void ) >> { >>int rv; >>struct utimbuf time; >> + struct timespec current_time; >>struct stat fstat; >> >> - /* First, an invalid filename. */ >> + /* ENOENT test case */ >> + >> + /* Case: Pass an invalid filename. */ >>rv = utime( "!This is an =invalid p@thname!!! :)", NULL ); >>rtems_test_assert( rv == -1 ); >>rtems_test_assert( errno == ENOENT ); >> >> - /* Now, the success test. */ >> + /* EACCES test case */ >> + >> + /* Case: Change user ID to someone besides root */ >> + rv = seteuid( 1 ); >> + rtems_test_assert( rv == 0 ); >> + >> + rv = utime( "testfile1.tst", NULL ); >> + rtems_test_assert( rv == -1 ); >> + rtems_test_assert( errno == EACCES ); >> + >> + rv = seteuid( 0 ); >> + rtems_test_assert( rv == 0 ); >> + >> + /* EINVAL test cases */ >> + >> + /* Case: Invalid access time */ >> + time.actime = -1; >> + time.modtime = 54321; >> + >> + rv = utime( "testfile1.tst", ); >> + rtems_test_assert( rv == -1 ); >> + rtems_test_assert( errno == EINVAL ); >> + >> + /* Case: Invalid modified time */ >> + time.actime = 12345; >> + time.modtime = -1; >> + >> + rv = utime( "testfile1.tst", ); >> + rtems_test_assert( rv == -1 ); >> + rtems_test_assert( errno == EINVAL ); >> + >> + /* Successful test cases */ >> + >> + /* Case: Test without times argument */ >> + clock_gettime( CLOCK_REALTIME, _time ); >> + >> + rv = utime( "testfile1.tst", NULL ); >> + rtems_test_assert( rv == 0 ); >> + >> + rv = stat( "testfile1.tst", ); >> + rtems_test_assert( rv == 0 ); >> + rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec ); >> + rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec ); >> + >> + /* Case: time is filled with valid values */ >>time.actime = 12345; >>time.modtime = 54321; >> >>rv = utime( "testfile1.tst", ); >>rtems_test_assert( rv == 0 ); >> >> - /* But, did it set the time? */ >> + /* Check that it actually changed the time */ >>rv = stat( "testfile1.tst", ); >>rtems_test_assert( rv == 0 ); >>rtems_test_assert(
Re: [PATCH v6 4/5] psx13: Added tests for utimensat() and futimens()
On Tue, May 18, 2021 at 3:03 PM Ryan Long wrote: > Improved tests for utime() and utimes() and update license. > > Close #4399 > --- > testsuites/psxtests/psx13/main.c | 5 +- > testsuites/psxtests/psx13/test.c | 499 > +-- > 2 files changed, 481 insertions(+), 23 deletions(-) > > diff --git a/testsuites/psxtests/psx13/main.c > b/testsuites/psxtests/psx13/main.c > index f9e7907..7a560f9 100644 > --- a/testsuites/psxtests/psx13/main.c > +++ b/testsuites/psxtests/psx13/main.c > @@ -1,5 +1,3 @@ > -/* SPDX-License-Identifier: BSD-2-Clause */ > - > Agree with Gedare. This shouldn't have been removed. There were some dates changed in the copyrights. Check all of the issues against all of the patches. > /** > * @file > * > @@ -8,8 +6,7 @@ > */ > > /* > - * COPYRIGHT (c) 1989-2009, 2021. > - * On-Line Applications Research Corporation (OAR). > + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation > (OAR). > This changes the years which is wrong. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > diff --git a/testsuites/psxtests/psx13/test.c > b/testsuites/psxtests/psx13/test.c > index e98b03a..0754dbc 100644 > --- a/testsuites/psxtests/psx13/test.c > +++ b/testsuites/psxtests/psx13/test.c > @@ -1,4 +1,4 @@ > -/* SPDX-License-Identifier: BSD-2-Clause */ > +/* SPDX-License-Identifier: BSD-2-Clause */ > > /** > * @file > @@ -17,12 +17,13 @@ > * - umask() > * - utime() > * - utimes() > + * - utimensat() > + * - futimens() > * - sync() > */ > > /* > - * COPYRIGHT (c) 1989-2009, 2021. > - * On-Line Applications Research Corporation (OAR). > + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation > (OAR). > Again a year change. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > @@ -52,6 +53,8 @@ > > #include > #include > +#include > +#include > #include > #include > #include > @@ -210,8 +213,7 @@ static void Dup2Test( void ) > } > > /** > - * @brief Exercises fdatasync(). Does NOT test the functionality of the > - *underlying fdatasync entry in the IMFS op table. > + * @brief Exercises fdatasync(). > */ > static void FDataSyncTest( void ) > { > @@ -259,60 +261,517 @@ static void UMaskTest( void ) > } > > /** > - * @brief Exercises utime(). Does not test the functionality of the > - *underlying utime entry in the IMFS op table. > + * @brief Exercises utime(). > */ > static void UTimeTest( void ) > { >int rv; >struct utimbuf time; > + struct timespec current_time; >struct stat fstat; > > - /* First, an invalid filename. */ > + /* ENOENT test case */ > + > + /* Case: Pass an invalid filename. */ >rv = utime( "!This is an =invalid p@thname!!! :)", NULL ); >rtems_test_assert( rv == -1 ); >rtems_test_assert( errno == ENOENT ); > > - /* Now, the success test. */ > + /* EACCES test case */ > + > + /* Case: Change user ID to someone besides root */ > + rv = seteuid( 1 ); > + rtems_test_assert( rv == 0 ); > + > + rv = utime( "testfile1.tst", NULL ); > + rtems_test_assert( rv == -1 ); > + rtems_test_assert( errno == EACCES ); > + > + rv = seteuid( 0 ); > + rtems_test_assert( rv == 0 ); > + > + /* EINVAL test cases */ > + > + /* Case: Invalid access time */ > + time.actime = -1; > + time.modtime = 54321; > + > + rv = utime( "testfile1.tst", ); > + rtems_test_assert( rv == -1 ); > + rtems_test_assert( errno == EINVAL ); > + > + /* Case: Invalid modified time */ > + time.actime = 12345; > + time.modtime = -1; > + > + rv = utime( "testfile1.tst", ); > + rtems_test_assert( rv == -1 ); > + rtems_test_assert( errno == EINVAL ); > + > + /* Successful test cases */ > + > + /* Case: Test without times argument */ > + clock_gettime( CLOCK_REALTIME, _time ); > + > + rv = utime( "testfile1.tst", NULL ); > + rtems_test_assert( rv == 0 ); > + > + rv = stat( "testfile1.tst", ); > + rtems_test_assert( rv == 0 ); > + rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec ); > + rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec ); > + > + /* Case: time is filled with valid values */ >time.actime = 12345; >time.modtime = 54321; > >rv = utime( "testfile1.tst", ); >rtems_test_assert( rv == 0 ); > > - /* But, did it set the time? */ > + /* Check that it actually changed the time */ >rv = stat( "testfile1.tst", ); >rtems_test_assert( rv == 0 ); >rtems_test_assert( fstat.st_atime == 12345 ); >rtems_test_assert( fstat.st_mtime == 54321 ); > - > - rv = utime( "testfile1.tst", NULL ); > - rtems_test_assert( rv == 0 ); > } > > /** > - * @brief Exercises utimes(). Does NOT test the functionality of the > - *underlying utime entry in the IMFS op table.
Re: [PATCH v6 4/5] psx13: Added tests for utimensat() and futimens()
On Tue, May 18, 2021 at 2:03 PM Ryan Long wrote: > > Improved tests for utime() and utimes() and update license. > > Close #4399 > --- > testsuites/psxtests/psx13/main.c | 5 +- > testsuites/psxtests/psx13/test.c | 499 > +-- > 2 files changed, 481 insertions(+), 23 deletions(-) > > diff --git a/testsuites/psxtests/psx13/main.c > b/testsuites/psxtests/psx13/main.c > index f9e7907..7a560f9 100644 > --- a/testsuites/psxtests/psx13/main.c > +++ b/testsuites/psxtests/psx13/main.c > @@ -1,5 +1,3 @@ > -/* SPDX-License-Identifier: BSD-2-Clause */ > - why this is being removed? > /** > * @file > * > @@ -8,8 +6,7 @@ > */ > > /* > - * COPYRIGHT (c) 1989-2009, 2021. > - * On-Line Applications Research Corporation (OAR). > + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > diff --git a/testsuites/psxtests/psx13/test.c > b/testsuites/psxtests/psx13/test.c > index e98b03a..0754dbc 100644 > --- a/testsuites/psxtests/psx13/test.c > +++ b/testsuites/psxtests/psx13/test.c > @@ -1,4 +1,4 @@ > -/* SPDX-License-Identifier: BSD-2-Clause */ > +/* SPDX-License-Identifier: BSD-2-Clause */ > > /** > * @file > @@ -17,12 +17,13 @@ > * - umask() > * - utime() > * - utimes() > + * - utimensat() > + * - futimens() > * - sync() > */ > > /* > - * COPYRIGHT (c) 1989-2009, 2021. > - * On-Line Applications Research Corporation (OAR). > + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > @@ -52,6 +53,8 @@ > > #include > #include > +#include > +#include > #include > #include > #include > @@ -210,8 +213,7 @@ static void Dup2Test( void ) > } > > /** > - * @brief Exercises fdatasync(). Does NOT test the functionality of the > - *underlying fdatasync entry in the IMFS op table. > + * @brief Exercises fdatasync(). > */ > static void FDataSyncTest( void ) > { > @@ -259,60 +261,517 @@ static void UMaskTest( void ) > } > > /** > - * @brief Exercises utime(). Does not test the functionality of the > - *underlying utime entry in the IMFS op table. > + * @brief Exercises utime(). > */ > static void UTimeTest( void ) > { >int rv; >struct utimbuf time; > + struct timespec current_time; >struct stat fstat; > > - /* First, an invalid filename. */ > + /* ENOENT test case */ > + > + /* Case: Pass an invalid filename. */ >rv = utime( "!This is an =invalid p@thname!!! :)", NULL ); >rtems_test_assert( rv == -1 ); >rtems_test_assert( errno == ENOENT ); > > - /* Now, the success test. */ > + /* EACCES test case */ > + > + /* Case: Change user ID to someone besides root */ > + rv = seteuid( 1 ); > + rtems_test_assert( rv == 0 ); > + > + rv = utime( "testfile1.tst", NULL ); > + rtems_test_assert( rv == -1 ); > + rtems_test_assert( errno == EACCES ); > + > + rv = seteuid( 0 ); > + rtems_test_assert( rv == 0 ); > + > + /* EINVAL test cases */ > + > + /* Case: Invalid access time */ > + time.actime = -1; > + time.modtime = 54321; > + > + rv = utime( "testfile1.tst", ); > + rtems_test_assert( rv == -1 ); > + rtems_test_assert( errno == EINVAL ); > + > + /* Case: Invalid modified time */ > + time.actime = 12345; > + time.modtime = -1; > + > + rv = utime( "testfile1.tst", ); > + rtems_test_assert( rv == -1 ); > + rtems_test_assert( errno == EINVAL ); > + > + /* Successful test cases */ > + > + /* Case: Test without times argument */ > + clock_gettime( CLOCK_REALTIME, _time ); > + > + rv = utime( "testfile1.tst", NULL ); > + rtems_test_assert( rv == 0 ); > + > + rv = stat( "testfile1.tst", ); > + rtems_test_assert( rv == 0 ); > + rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec ); > + rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec ); > + > + /* Case: time is filled with valid values */ >time.actime = 12345; >time.modtime = 54321; > >rv = utime( "testfile1.tst", ); >rtems_test_assert( rv == 0 ); > > - /* But, did it set the time? */ > + /* Check that it actually changed the time */ >rv = stat( "testfile1.tst", ); >rtems_test_assert( rv == 0 ); >rtems_test_assert( fstat.st_atime == 12345 ); >rtems_test_assert( fstat.st_mtime == 54321 ); > - > - rv = utime( "testfile1.tst", NULL ); > - rtems_test_assert( rv == 0 ); > } > > /** > - * @brief Exercises utimes(). Does NOT test the functionality of the > - *underlying utime entry in the IMFS op table. > + * @brief Exercises utimes(). > */ > static void UTimesTest( void ) > { >int rv; >struct timeval time[2]; > + struct timespec current_time; >struct stat fstat; > > - /* First, an