From 07bd3871ab2c409c836f596a529fde643e4b6210 Mon Sep 17 00:00:00 2001 From: Loris Nardo Date: Sat, 6 Jul 2024 06:18:20 +0200 Subject: [PATCH] testsuites: Allow finer control on the fstest result Changed fstest support to allow control on the test result of each fstest, updated all fstest accordingly. Modified FS_FAIL macro to fail hard and not just print a message which rtems-test runner ignores. Split failing test cases from the ones that passes; added fsrenameexisting, fsrenamepermexisting, fsrmdirparent, fsrenamelongname and fsrenamemaxlinks test cases. Marked fsrenameexisting, fsrenamepermexisting as expected to fail due to #2169. Marked fsrmdirparent as expected to fail, covered by #5071. Marked fssymlink as expected to fail due to rename problems partially covered by #2169. Marked rfsfsrenamelongname as expected to fail, covered by #5069. Marked *fsrenamemaxlinks as expected to fail, covered by #5070. Marked jffs2fsrenamelongname and jffs2nandfsrenamelongname as expected to fail, as JFFS2 seems to not have a limit on the file name, covered by #5073 --- spec/build/bsps/tst.yml | 63 +++ spec/build/testsuites/fstests/grp.yml | 58 +++ .../fstests/imfsfsrenameexisting.yml | 21 + .../fstests/imfsfsrenamepermexisting.yml | 21 + .../testsuites/fstests/imfsfsrmdirparent.yml | 21 + .../testsuites/fstests/jffs2fsrename.yml | 22 + .../fstests/jffs2fsrenameexisting.yml | 22 + .../fstests/jffs2fsrenamelongname.yml | 22 + .../fstests/jffs2fsrenamemaxlinks.yml | 22 + .../fstests/jffs2fsrenamepermexisting.yml | 22 + .../testsuites/fstests/jffs2fsrmdirparent.yml | 22 + .../testsuites/fstests/jffs2nandfsrename.yml | 22 + .../fstests/jffs2nandfsrenameexisting.yml | 22 + .../fstests/jffs2nandfsrenamelongname.yml | 22 + .../fstests/jffs2nandfsrenamemaxlinks.yml | 22 + .../fstests/jffs2nandfsrenamepermexisting.yml | 22 + .../fstests/jffs2nandfsrmdirparent.yml | 22 + .../fstests/mdosfsfsrenameexisting.yml | 21 + .../fstests/mdosfsfsrenamelongname.yml | 21 + .../fstests/mdosfsfsrenamemaxlinks.yml | 21 + .../fstests/mdosfsfsrmdirparent.yml | 21 + .../fstests/mimfsfsrenameexisting.yml | 21 + .../fstests/mimfsfsrenamelongname.yml | 21 + .../fstests/mimfsfsrenamemaxlinks.yml | 21 + .../fstests/mimfsfsrenamepermexisting.yml | 21 + .../testsuites/fstests/mimfsfsrmdirparent.yml | 21 + .../fstests/mrfsfsrenameexisting.yml | 21 + .../fstests/mrfsfsrenamelongname.yml | 21 + .../fstests/mrfsfsrenamemaxlinks.yml | 21 + .../fstests/mrfsfsrenamepermexisting.yml | 21 + .../testsuites/fstests/mrfsfsrmdirparent.yml | 21 + testsuites/fstests/fserror/test.c | 15 +- testsuites/fstests/fsfpathconf/test.c | 2 +- testsuites/fstests/fsjffs2gc01/init.c | 1 + testsuites/fstests/fslink/test.c | 1 + testsuites/fstests/fspatheval/test.c | 9 +- testsuites/fstests/fspermission/test.c | 298 +---------- testsuites/fstests/fsrdwr/init.c | 1 + testsuites/fstests/fsrename/test.c | 400 +-------------- testsuites/fstests/fsrenameexisting/test.c | 465 ++++++++++++++++++ testsuites/fstests/fsrenamelongname/test.c | 108 ++++ testsuites/fstests/fsrenamemaxlinks/test.c | 137 ++++++ .../fstests/fsrenamepermexisting/test.c | 428 ++++++++++++++++ testsuites/fstests/fsrfsbitmap01/test.c | 1 + testsuites/fstests/fsrmdirparent/test.c | 88 ++++ testsuites/fstests/fsscandir01/init.c | 1 + testsuites/fstests/fsstatvfs/test.c | 1 + testsuites/fstests/fssymlink/test.c | 14 +- testsuites/fstests/fstime/test.c | 1 + testsuites/fstests/support/fstest.h | 3 + testsuites/fstests/support/fstest_support.c | 13 +- 51 files changed, 2009 insertions(+), 720 deletions(-) create mode 100644 spec/build/testsuites/fstests/imfsfsrenameexisting.yml create mode 100644 spec/build/testsuites/fstests/imfsfsrenamepermexisting.yml create mode 100644 spec/build/testsuites/fstests/imfsfsrmdirparent.yml create mode 100644 spec/build/testsuites/fstests/jffs2fsrename.yml create mode 100644 spec/build/testsuites/fstests/jffs2fsrenameexisting.yml create mode 100644 spec/build/testsuites/fstests/jffs2fsrenamelongname.yml create mode 100644 spec/build/testsuites/fstests/jffs2fsrenamemaxlinks.yml create mode 100644 spec/build/testsuites/fstests/jffs2fsrenamepermexisting.yml create mode 100644 spec/build/testsuites/fstests/jffs2fsrmdirparent.yml create mode 100644 spec/build/testsuites/fstests/jffs2nandfsrename.yml create mode 100644 spec/build/testsuites/fstests/jffs2nandfsrenameexisting.yml create mode 100644 spec/build/testsuites/fstests/jffs2nandfsrenamelongname.yml create mode 100644 spec/build/testsuites/fstests/jffs2nandfsrenamemaxlinks.yml create mode 100644 spec/build/testsuites/fstests/jffs2nandfsrenamepermexisting.yml create mode 100644 spec/build/testsuites/fstests/jffs2nandfsrmdirparent.yml create mode 100644 spec/build/testsuites/fstests/mdosfsfsrenameexisting.yml create mode 100644 spec/build/testsuites/fstests/mdosfsfsrenamelongname.yml create mode 100644 spec/build/testsuites/fstests/mdosfsfsrenamemaxlinks.yml create mode 100644 spec/build/testsuites/fstests/mdosfsfsrmdirparent.yml create mode 100644 spec/build/testsuites/fstests/mimfsfsrenameexisting.yml create mode 100644 spec/build/testsuites/fstests/mimfsfsrenamelongname.yml create mode 100644 spec/build/testsuites/fstests/mimfsfsrenamemaxlinks.yml create mode 100644 spec/build/testsuites/fstests/mimfsfsrenamepermexisting.yml create mode 100644 spec/build/testsuites/fstests/mimfsfsrmdirparent.yml create mode 100644 spec/build/testsuites/fstests/mrfsfsrenameexisting.yml create mode 100644 spec/build/testsuites/fstests/mrfsfsrenamelongname.yml create mode 100644 spec/build/testsuites/fstests/mrfsfsrenamemaxlinks.yml create mode 100644 spec/build/testsuites/fstests/mrfsfsrenamepermexisting.yml create mode 100644 spec/build/testsuites/fstests/mrfsfsrmdirparent.yml create mode 100644 testsuites/fstests/fsrenameexisting/test.c create mode 100644 testsuites/fstests/fsrenamelongname/test.c create mode 100644 testsuites/fstests/fsrenamemaxlinks/test.c create mode 100644 testsuites/fstests/fsrenamepermexisting/test.c create mode 100644 testsuites/fstests/fsrmdirparent/test.c diff --git a/spec/build/bsps/tst.yml b/spec/build/bsps/tst.yml index 739ab8c6c4..de00d8f7f2 100644 --- a/spec/build/bsps/tst.yml +++ b/spec/build/bsps/tst.yml @@ -22,6 +22,69 @@ actions: state: expected-fail tests: - psxfenv01 +- set-test-state: + reason: | + Fails because of #2169, rename to existing entries is + not supported + state: expected-fail + tests: + - imfsfsrenameexisting + - imfsfsrenamepermexisting + - jffs2fsrenameexisting + - jffs2fsrenamepermexisting + - jffs2nandfsrenameexisting + - jffs2nandfsrenamepermexisting + - mdosfsfsrenameexisting + - mimfsfsrenameexisting + - mimfsfsrenamepermexisting + - mrfsfsrenameexisting + - mrfsfsrenamepermexisting +- set-test-state: + reason: | + Fails because of #5071, dot-dot as last part of a path + is treated as valid + state: expected-fail + tests: + - imfsfsrmdirparent + - jffs2fsrmdirparent + - jffs2nandfsrmdirparent + - mdosfsfsrmdirparent + - mimfsfsrmdirparent + - mrfsfsrmdirparent +- set-test-state: + reason: | + Fails because of #2169 and other rename issue + state: expected-fail + tests: + - imfsfssymlink + - jffs2fssymlink + - jffs2nandfssymlink + - mimfsfssymlink + - mrfsfssymlink +- set-test-state: + reason: | + Fails because of #5069, NAME_MAX is ignored by RFS + state: expected-fail + tests: + - mrfsfsrenamelongname +- set-test-state: + reason: | + Fails because of #5070, this test seems invalid + state: expected-fail + tests: + - jffs2fsrenamemaxlinks + - jffs2nandfsrenamemaxlinks + - mdosfsfsrenamemaxlinks + - mimfsfsrenamemaxlinks + - mrfsfsrenamemaxlinks +- set-test-state: + reason: | + Fails because of #5073, JFFS2 seems to not have appart + limits on file name length + state: expected-fail + tests: + - jffs2fsrenamelongname + - jffs2nandfsrenamelongname build-type: option copyrights: - Copyright (C) 2020 embedded brains GmbH & Co. KG diff --git a/spec/build/testsuites/fstests/grp.yml b/spec/build/testsuites/fstests/grp.yml index 425a3b4282..02ebf6b841 100644 --- a/spec/build/testsuites/fstests/grp.yml +++ b/spec/build/testsuites/fstests/grp.yml @@ -71,6 +71,12 @@ links: uid: imfsfspermission - role: build-dependency uid: imfsfsrdwr +- role: build-dependency + uid: imfsfsrenameexisting +- role: build-dependency + uid: imfsfsrenamepermexisting +- role: build-dependency + uid: imfsfsrmdirparent - role: build-dependency uid: imfsfsscandir01 - role: build-dependency @@ -87,6 +93,18 @@ links: uid: jffs2fspermission - role: build-dependency uid: jffs2fsrdwr +- role: build-dependency + uid: jffs2fsrename +- role: build-dependency + uid: jffs2fsrenameexisting +- role: build-dependency + uid: jffs2fsrenamelongname +- role: build-dependency + uid: jffs2fsrenamemaxlinks +- role: build-dependency + uid: jffs2fsrenamepermexisting +- role: build-dependency + uid: jffs2fsrmdirparent - role: build-dependency uid: jffs2fsscandir01 - role: build-dependency @@ -103,6 +121,18 @@ links: uid: jffs2nandfspermission - role: build-dependency uid: jffs2nandfsrdwr +- role: build-dependency + uid: jffs2nandfsrename +- role: build-dependency + uid: jffs2nandfsrenameexisting +- role: build-dependency + uid: jffs2nandfsrenamelongname +- role: build-dependency + uid: jffs2nandfsrenamemaxlinks +- role: build-dependency + uid: jffs2nandfsrenamepermexisting +- role: build-dependency + uid: jffs2nandfsrmdirparent - role: build-dependency uid: jffs2nandfsscandir01 - role: build-dependency @@ -117,6 +147,14 @@ links: uid: mdosfsfsrdwr - role: build-dependency uid: mdosfsfsrename +- role: build-dependency + uid: mdosfsfsrenameexisting +- role: build-dependency + uid: mdosfsfsrenamelongname +- role: build-dependency + uid: mdosfsfsrenamemaxlinks +- role: build-dependency + uid: mdosfsfsrmdirparent - role: build-dependency uid: mdosfsfsscandir01 - role: build-dependency @@ -135,6 +173,16 @@ links: uid: mimfsfsrdwr - role: build-dependency uid: mimfsfsrename +- role: build-dependency + uid: mimfsfsrenameexisting +- role: build-dependency + uid: mimfsfsrenamelongname +- role: build-dependency + uid: mimfsfsrenamemaxlinks +- role: build-dependency + uid: mimfsfsrenamepermexisting +- role: build-dependency + uid: mimfsfsrmdirparent - role: build-dependency uid: mimfsfsscandir01 - role: build-dependency @@ -155,6 +203,16 @@ links: uid: mrfsfsrdwr - role: build-dependency uid: mrfsfsrename +- role: build-dependency + uid: mrfsfsrenameexisting +- role: build-dependency + uid: mrfsfsrenamelongname +- role: build-dependency + uid: mrfsfsrenamemaxlinks +- role: build-dependency + uid: mrfsfsrenamepermexisting +- role: build-dependency + uid: mrfsfsrmdirparent - role: build-dependency uid: mrfsfsscandir01 - role: build-dependency diff --git a/spec/build/testsuites/fstests/imfsfsrenameexisting.yml b/spec/build/testsuites/fstests/imfsfsrenameexisting.yml new file mode 100644 index 0000000000..9dccd68e08 --- /dev/null +++ b/spec/build/testsuites/fstests/imfsfsrenameexisting.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/imfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenameexisting/test.c +stlib: [] +target: testsuites/fstests/imfs_fsrenameexisting.exe +type: build +use-after: [] +use-before: +- testimfs diff --git a/spec/build/testsuites/fstests/imfsfsrenamepermexisting.yml b/spec/build/testsuites/fstests/imfsfsrenamepermexisting.yml new file mode 100644 index 0000000000..fbd041ae7c --- /dev/null +++ b/spec/build/testsuites/fstests/imfsfsrenamepermexisting.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/imfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamepermexisting/test.c +stlib: [] +target: testsuites/fstests/imfs_fsrenamepermexisting.exe +type: build +use-after: [] +use-before: +- testimfs diff --git a/spec/build/testsuites/fstests/imfsfsrmdirparent.yml b/spec/build/testsuites/fstests/imfsfsrmdirparent.yml new file mode 100644 index 0000000000..e593f6f131 --- /dev/null +++ b/spec/build/testsuites/fstests/imfsfsrmdirparent.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/imfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrmdirparent/test.c +stlib: [] +target: testsuites/fstests/imfs_fsrmdirparent.exe +type: build +use-after: [] +use-before: +- testimfs diff --git a/spec/build/testsuites/fstests/jffs2fsrename.yml b/spec/build/testsuites/fstests/jffs2fsrename.yml new file mode 100644 index 0000000000..9aac88b9eb --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2fsrename.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrename/test.c +stlib: [] +target: testsuites/fstests/jffs2_fsrename.exe +type: build +use-after: [] +use-before: +- testjffs2 +- jffs2 diff --git a/spec/build/testsuites/fstests/jffs2fsrenameexisting.yml b/spec/build/testsuites/fstests/jffs2fsrenameexisting.yml new file mode 100644 index 0000000000..3a10cce30f --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2fsrenameexisting.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenameexisting/test.c +stlib: [] +target: testsuites/fstests/jffs2_fsrenameexisting.exe +type: build +use-after: [] +use-before: +- testjffs2 +- jffs2 diff --git a/spec/build/testsuites/fstests/jffs2fsrenamelongname.yml b/spec/build/testsuites/fstests/jffs2fsrenamelongname.yml new file mode 100644 index 0000000000..8b984efb0b --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2fsrenamelongname.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamelongname/test.c +stlib: [] +target: testsuites/fstests/jffs2_fsrenamelongname.exe +type: build +use-after: [] +use-before: +- testjffs2 +- jffs2 diff --git a/spec/build/testsuites/fstests/jffs2fsrenamemaxlinks.yml b/spec/build/testsuites/fstests/jffs2fsrenamemaxlinks.yml new file mode 100644 index 0000000000..c1704b03b3 --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2fsrenamemaxlinks.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamemaxlinks/test.c +stlib: [] +target: testsuites/fstests/jffs2_fsrenamemaxlinks.exe +type: build +use-after: [] +use-before: +- testjffs2 +- jffs2 diff --git a/spec/build/testsuites/fstests/jffs2fsrenamepermexisting.yml b/spec/build/testsuites/fstests/jffs2fsrenamepermexisting.yml new file mode 100644 index 0000000000..95256aeffb --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2fsrenamepermexisting.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamepermexisting/test.c +stlib: [] +target: testsuites/fstests/jffs2_fsrenamepermexisting.exe +type: build +use-after: [] +use-before: +- testjffs2 +- jffs2 diff --git a/spec/build/testsuites/fstests/jffs2fsrmdirparent.yml b/spec/build/testsuites/fstests/jffs2fsrmdirparent.yml new file mode 100644 index 0000000000..5b0c6e6636 --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2fsrmdirparent.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrmdirparent/test.c +stlib: [] +target: testsuites/fstests/jffs2_fsrmdirparent.exe +type: build +use-after: [] +use-before: +- testjffs2 +- jffs2 diff --git a/spec/build/testsuites/fstests/jffs2nandfsrename.yml b/spec/build/testsuites/fstests/jffs2nandfsrename.yml new file mode 100644 index 0000000000..8c1460a609 --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2nandfsrename.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2023 On-Line Applications Research (OAR) +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_nand_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrename/test.c +stlib: [] +target: testsuites/fstests/jffs2nand_fsrename.exe +type: build +use-after: [] +use-before: +- testjffs2nand +- jffs2 diff --git a/spec/build/testsuites/fstests/jffs2nandfsrenameexisting.yml b/spec/build/testsuites/fstests/jffs2nandfsrenameexisting.yml new file mode 100644 index 0000000000..ddd0b552df --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2nandfsrenameexisting.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2023 On-Line Applications Research (OAR) +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_nand_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenameexisting/test.c +stlib: [] +target: testsuites/fstests/jffs2nand_fsrenameexisting.exe +type: build +use-after: [] +use-before: +- testjffs2nand +- jffs2 diff --git a/spec/build/testsuites/fstests/jffs2nandfsrenamelongname.yml b/spec/build/testsuites/fstests/jffs2nandfsrenamelongname.yml new file mode 100644 index 0000000000..43d8ca0f30 --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2nandfsrenamelongname.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2023 On-Line Applications Research (OAR) +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_nand_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamelongname/test.c +stlib: [] +target: testsuites/fstests/jffs2nand_fsrenamelongname.exe +type: build +use-after: [] +use-before: +- testjffs2nand +- jffs2 diff --git a/spec/build/testsuites/fstests/jffs2nandfsrenamemaxlinks.yml b/spec/build/testsuites/fstests/jffs2nandfsrenamemaxlinks.yml new file mode 100644 index 0000000000..f3783cef4e --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2nandfsrenamemaxlinks.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2023 On-Line Applications Research (OAR) +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_nand_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamemaxlinks/test.c +stlib: [] +target: testsuites/fstests/jffs2nand_fsrenamemaxlinks.exe +type: build +use-after: [] +use-before: +- testjffs2nand +- jffs2 diff --git a/spec/build/testsuites/fstests/jffs2nandfsrenamepermexisting.yml b/spec/build/testsuites/fstests/jffs2nandfsrenamepermexisting.yml new file mode 100644 index 0000000000..82cf230d4f --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2nandfsrenamepermexisting.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2023 On-Line Applications Research (OAR) +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_nand_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamepermexisting/test.c +stlib: [] +target: testsuites/fstests/jffs2nand_fsrenamepermexisting.exe +type: build +use-after: [] +use-before: +- testjffs2nand +- jffs2 diff --git a/spec/build/testsuites/fstests/jffs2nandfsrmdirparent.yml b/spec/build/testsuites/fstests/jffs2nandfsrmdirparent.yml new file mode 100644 index 0000000000..64a5e10ec4 --- /dev/null +++ b/spec/build/testsuites/fstests/jffs2nandfsrmdirparent.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2023 On-Line Applications Research (OAR) +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/jffs2_nand_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrmdirparent/test.c +stlib: [] +target: testsuites/fstests/jffs2nand_fsrmdirparent.exe +type: build +use-after: [] +use-before: +- testjffs2nand +- jffs2 diff --git a/spec/build/testsuites/fstests/mdosfsfsrenameexisting.yml b/spec/build/testsuites/fstests/mdosfsfsrenameexisting.yml new file mode 100644 index 0000000000..ca6ed559ed --- /dev/null +++ b/spec/build/testsuites/fstests/mdosfsfsrenameexisting.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mdosfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenameexisting/test.c +stlib: [] +target: testsuites/fstests/mdosfs_fsrenameexisting.exe +type: build +use-after: [] +use-before: +- testdosfs diff --git a/spec/build/testsuites/fstests/mdosfsfsrenamelongname.yml b/spec/build/testsuites/fstests/mdosfsfsrenamelongname.yml new file mode 100644 index 0000000000..43c8f764bb --- /dev/null +++ b/spec/build/testsuites/fstests/mdosfsfsrenamelongname.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mdosfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamelongname/test.c +stlib: [] +target: testsuites/fstests/mdosfs_fsrenamelongname.exe +type: build +use-after: [] +use-before: +- testdosfs diff --git a/spec/build/testsuites/fstests/mdosfsfsrenamemaxlinks.yml b/spec/build/testsuites/fstests/mdosfsfsrenamemaxlinks.yml new file mode 100644 index 0000000000..2dc338de1b --- /dev/null +++ b/spec/build/testsuites/fstests/mdosfsfsrenamemaxlinks.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mdosfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamemaxlinks/test.c +stlib: [] +target: testsuites/fstests/mdosfs_fsrenamemaxlinks.exe +type: build +use-after: [] +use-before: +- testdosfs diff --git a/spec/build/testsuites/fstests/mdosfsfsrmdirparent.yml b/spec/build/testsuites/fstests/mdosfsfsrmdirparent.yml new file mode 100644 index 0000000000..8b0172d350 --- /dev/null +++ b/spec/build/testsuites/fstests/mdosfsfsrmdirparent.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mdosfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrmdirparent/test.c +stlib: [] +target: testsuites/fstests/mdosfs_fsrmdirparent.exe +type: build +use-after: [] +use-before: +- testdosfs diff --git a/spec/build/testsuites/fstests/mimfsfsrenameexisting.yml b/spec/build/testsuites/fstests/mimfsfsrenameexisting.yml new file mode 100644 index 0000000000..8c2cc3a9ee --- /dev/null +++ b/spec/build/testsuites/fstests/mimfsfsrenameexisting.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mimfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenameexisting/test.c +stlib: [] +target: testsuites/fstests/mimfs_fsrenameexisting.exe +type: build +use-after: [] +use-before: +- testmimfs diff --git a/spec/build/testsuites/fstests/mimfsfsrenamelongname.yml b/spec/build/testsuites/fstests/mimfsfsrenamelongname.yml new file mode 100644 index 0000000000..92891ae825 --- /dev/null +++ b/spec/build/testsuites/fstests/mimfsfsrenamelongname.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mimfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamelongname/test.c +stlib: [] +target: testsuites/fstests/mimfs_fsrenamelongname.exe +type: build +use-after: [] +use-before: +- testmimfs diff --git a/spec/build/testsuites/fstests/mimfsfsrenamemaxlinks.yml b/spec/build/testsuites/fstests/mimfsfsrenamemaxlinks.yml new file mode 100644 index 0000000000..dc27a1e7c1 --- /dev/null +++ b/spec/build/testsuites/fstests/mimfsfsrenamemaxlinks.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mimfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamemaxlinks/test.c +stlib: [] +target: testsuites/fstests/mimfs_fsrenamemaxlinks.exe +type: build +use-after: [] +use-before: +- testmimfs diff --git a/spec/build/testsuites/fstests/mimfsfsrenamepermexisting.yml b/spec/build/testsuites/fstests/mimfsfsrenamepermexisting.yml new file mode 100644 index 0000000000..085fac5e76 --- /dev/null +++ b/spec/build/testsuites/fstests/mimfsfsrenamepermexisting.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mimfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamepermexisting/test.c +stlib: [] +target: testsuites/fstests/mimfs_fsrenamepermexisting.exe +type: build +use-after: [] +use-before: +- testmimfs diff --git a/spec/build/testsuites/fstests/mimfsfsrmdirparent.yml b/spec/build/testsuites/fstests/mimfsfsrmdirparent.yml new file mode 100644 index 0000000000..1b695e9e74 --- /dev/null +++ b/spec/build/testsuites/fstests/mimfsfsrmdirparent.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mimfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrmdirparent/test.c +stlib: [] +target: testsuites/fstests/mimfs_fsrmdirparent.exe +type: build +use-after: [] +use-before: +- testmimfs diff --git a/spec/build/testsuites/fstests/mrfsfsrenameexisting.yml b/spec/build/testsuites/fstests/mrfsfsrenameexisting.yml new file mode 100644 index 0000000000..245faa7e37 --- /dev/null +++ b/spec/build/testsuites/fstests/mrfsfsrenameexisting.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mrfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenameexisting/test.c +stlib: [] +target: testsuites/fstests/mrfs_fsrenameexisting.exe +type: build +use-after: [] +use-before: +- testrfs diff --git a/spec/build/testsuites/fstests/mrfsfsrenamelongname.yml b/spec/build/testsuites/fstests/mrfsfsrenamelongname.yml new file mode 100644 index 0000000000..dceb592d6a --- /dev/null +++ b/spec/build/testsuites/fstests/mrfsfsrenamelongname.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mrfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamelongname/test.c +stlib: [] +target: testsuites/fstests/mrfs_fsrenamelongname.exe +type: build +use-after: [] +use-before: +- testrfs diff --git a/spec/build/testsuites/fstests/mrfsfsrenamemaxlinks.yml b/spec/build/testsuites/fstests/mrfsfsrenamemaxlinks.yml new file mode 100644 index 0000000000..ff79782ce1 --- /dev/null +++ b/spec/build/testsuites/fstests/mrfsfsrenamemaxlinks.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mrfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamemaxlinks/test.c +stlib: [] +target: testsuites/fstests/mrfs_fsrenamemaxlinks.exe +type: build +use-after: [] +use-before: +- testrfs diff --git a/spec/build/testsuites/fstests/mrfsfsrenamepermexisting.yml b/spec/build/testsuites/fstests/mrfsfsrenamepermexisting.yml new file mode 100644 index 0000000000..c2b5ea930c --- /dev/null +++ b/spec/build/testsuites/fstests/mrfsfsrenamepermexisting.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mrfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrenamepermexisting/test.c +stlib: [] +target: testsuites/fstests/mrfs_fsrenamepermexisting.exe +type: build +use-after: [] +use-before: +- testrfs diff --git a/spec/build/testsuites/fstests/mrfsfsrmdirparent.yml b/spec/build/testsuites/fstests/mrfsfsrmdirparent.yml new file mode 100644 index 0000000000..5a286571e2 --- /dev/null +++ b/spec/build/testsuites/fstests/mrfsfsrmdirparent.yml @@ -0,0 +1,21 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2020 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: +- testsuites/fstests/mrfs_support +ldflags: [] +links: [] +source: +- testsuites/fstests/fsrmdirparent/test.c +stlib: [] +target: testsuites/fstests/mrfs_fsrmdirparent.exe +type: build +use-after: [] +use-before: +- testrfs diff --git a/testsuites/fstests/fserror/test.c b/testsuites/fstests/fserror/test.c index 60b7b08584..c209717ce2 100644 --- a/testsuites/fstests/fserror/test.c +++ b/testsuites/fstests/fserror/test.c @@ -45,6 +45,7 @@ #include const char rtems_test_name[] = "FSERROR " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; static void open_mkdir_error (void) { @@ -135,7 +136,6 @@ static void rename_error (void) char *name01 = "name01"; char *name02 = "name02"; char *name03 = "name03"; - char *nonexistence = "name04"; char name[20]; @@ -171,11 +171,6 @@ static void rename_error (void) status = rename (name02, name01); rtems_test_assert (status != 0); rtems_test_assert (errno == EEXIST || errno == ENOTEMPTY); - /* - * The new directory pathname contains a path prefix - * that names the old directory. - */ - EXPECT_ERROR (EINVAL, rename, name01, name); /* * The new argument points to a directory and * the old argument points to a file that is not a directory. @@ -183,15 +178,11 @@ static void rename_error (void) fd = creat (name03, mode); status = close (fd); rtems_test_assert (status == 0); - EXPECT_ERROR (EISDIR, rename, name03, name02); /* * The link named by old does not name an existing file, * or either old or new points to an empty string. */ - - EXPECT_ERROR (ENOENT, rename, nonexistence, name01); - EXPECT_ERROR (ENOENT, rename, "", name01); EXPECT_ERROR (ENOENT, rename, name01, ""); /* @@ -201,9 +192,7 @@ static void rename_error (void) */ sprintf (name, "%s/%s", name03, name01); - EXPECT_ERROR (ENOTDIR, rename, name, name03); EXPECT_ERROR (ENOTDIR, rename, name03, name); - EXPECT_ERROR (ENOTDIR, rename, name02, name03); /* * Go back to parent directory @@ -284,8 +273,6 @@ static void rmdir_unlink_error (void) * or there are hard links to the directory other than * dot or a single entry in dot-dot. */ - - EXPECT_ERROR (ENOTEMPTY, rmdir, ".."); EXPECT_ERROR (ENOTEMPTY, rmdir, "tmp"); diff --git a/testsuites/fstests/fsfpathconf/test.c b/testsuites/fstests/fsfpathconf/test.c index a3a1b22132..51b476c053 100644 --- a/testsuites/fstests/fsfpathconf/test.c +++ b/testsuites/fstests/fsfpathconf/test.c @@ -48,6 +48,7 @@ #include "tmacros.h" const char rtems_test_name[] = "FSFPATHCONF " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; static void fpathconf_test(void){ @@ -105,7 +106,6 @@ static void fpathconf_test(void){ } void test(void){ - fpathconf_test(); } diff --git a/testsuites/fstests/fsjffs2gc01/init.c b/testsuites/fstests/fsjffs2gc01/init.c index 4d29373b90..7c047fa012 100644 --- a/testsuites/fstests/fsjffs2gc01/init.c +++ b/testsuites/fstests/fsjffs2gc01/init.c @@ -41,6 +41,7 @@ #include const char rtems_test_name[] = "FSJFFS2GC 1"; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; static const rtems_jffs2_info info_initial = { .flash_size = 131072, diff --git a/testsuites/fstests/fslink/test.c b/testsuites/fstests/fslink/test.c index 3eb09e8e08..402b5a8968 100644 --- a/testsuites/fstests/fslink/test.c +++ b/testsuites/fstests/fslink/test.c @@ -46,6 +46,7 @@ #include const char rtems_test_name[] = "FSLINK " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; /* * Test if the successful call works as expect diff --git a/testsuites/fstests/fspatheval/test.c b/testsuites/fstests/fspatheval/test.c index 855af33cf1..e2c5f05e39 100644 --- a/testsuites/fstests/fspatheval/test.c +++ b/testsuites/fstests/fspatheval/test.c @@ -46,6 +46,7 @@ #define BUF_SIZE 100 const char rtems_test_name[] = "FSPATHEVAL " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; static void make_multiple_files (char **files,int is_directory) { @@ -54,14 +55,14 @@ static void make_multiple_files (char **files,int is_directory) int fd; i = 0; - if (is_directory){ + if (is_directory) { while (files[i]) { printf ("Making directory %s\n", files[i]); status = mkdir (files[i], S_IRWXU); rtems_test_assert (!status); i++; } - }else { + } else { while (files[i]) { printf ("Create file %s\n", files[i]); fd=creat(files[i],S_IRWXU); @@ -84,14 +85,14 @@ static void remove_multiple_files (char **files,int is_directory) i++; } - if (is_directory){ + if (is_directory) { while (i) { i--; printf ("Removing directory %s\n", files[i]); status = rmdir (files[i]); rtems_test_assert (!status); } - }else { + } else { while (i) { i--; printf ("Removing file %s\n", files[i]); diff --git a/testsuites/fstests/fspermission/test.c b/testsuites/fstests/fspermission/test.c index 2f38d1c5db..b953104e9a 100644 --- a/testsuites/fstests/fspermission/test.c +++ b/testsuites/fstests/fspermission/test.c @@ -45,6 +45,7 @@ #include const char rtems_test_name[] = "FSPERMISSION " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; /* * Test the umask @@ -516,136 +517,6 @@ static void root_test(void ) rtems_test_assert(fd==-1); } -static void rename_write_permission_test (void) -{ - int fd; - int status; - int rv; - - const char *name01 = "name01"; - const char *name02 = "name02"; - - const char *dir01 = "dir01"; - const char *dir02 = "dir02"; - - char path01[20]; - - mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; - mode_t no_write_access = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP - | S_IROTH | S_IXOTH; - - const char *wd = __func__; - - /* - * Create a new directory and change the current directory to this - */ - - status = mkdir (wd, mode); - rtems_test_assert (status == 0); - status = chdir (wd); - rtems_test_assert (status == 0); - - /* - * The new argument points to a file and - * the old argument points to another file, - * both inside a directory with no write permission. - */ - - puts ("\nRename two files on a directory with no write permission \n"); - - status = mkdir (dir01, mode); - rtems_test_assert (status == 0); - - status = chdir (dir01); - rtems_test_assert (status == 0); - - fd = creat (name01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - fd = creat (name02, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - status = chmod (".", no_write_access); - rtems_test_assert (status == 0); - - EXPECT_ERROR (EACCES, rename, name01 , name02); - - status = chdir (".."); - rtems_test_assert (status == 0); - - /* - * The new argument points to a file in a directory with no write access and - * the old argument points to another file on a directory with write access. - */ - - puts ("\nRename file between two directories, with and without write access\n"); - - status = mkdir (dir02, mode); - rtems_test_assert (status == 0); - - status = chdir (dir02); - rtems_test_assert (status == 0); - - fd = creat (name01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - rv = snprintf (path01, sizeof(path01), "../%s/%s", dir01, name02); - rtems_test_assert (rv < sizeof(path01)); - EXPECT_ERROR (EACCES, rename, name01, path01); - - /* - * The new argument points to a file in a directory with write access and - * the old argument points to another file on a directory without write access. - */ - - EXPECT_ERROR (EACCES, rename, path01, name01); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, unlink, name01); - - rv = snprintf (path01, sizeof(path01), "../%s", dir01); - rtems_test_assert (rv < sizeof(path01)); - status = chmod (path01, mode); - rtems_test_assert (status == 0); - - rv = snprintf (path01, sizeof(path01), "../%s/%s", dir01, name01); - rtems_test_assert (rv < sizeof(path01)); - EXPECT_EQUAL (0, unlink, path01); - - rv = snprintf (path01, sizeof(path01), "../%s/%s", dir01, name02); - rtems_test_assert (rv < sizeof(path01)); - EXPECT_EQUAL (0, unlink, path01); - - status = chdir (".."); - rtems_test_assert (status == 0); - - EXPECT_EQUAL (0, rmdir, dir01); - EXPECT_EQUAL (0, rmdir, dir02); - - /* - * Go back to parent directory - */ - - status = chdir (".."); - rtems_test_assert (status == 0); - - /* - * Remove test directory - */ - - status = rmdir (wd); - rtems_test_assert (status == 0); -} - static void rename_search_permission_test (void) { int fd; @@ -656,7 +527,6 @@ static void rename_search_permission_test (void) const char *name02 = "name02"; const char *dir01 = "dir01"; - const char *dir02 = "dir02"; char path01[20]; char path02[20]; @@ -706,44 +576,9 @@ static void rename_search_permission_test (void) EXPECT_ERROR (EACCES, rename, path01 , path02); - /* - * The new argument points to a file in a directory with no execute access and - * the old argument points to another file on a directory with execute access. - */ - - puts ("\nRename file between two directories, with and without execute access\n"); - - status = mkdir (dir02, mode); - rtems_test_assert (status == 0); - - status = chdir (dir02); - rtems_test_assert (status == 0); - - fd = creat (name01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - status = chdir (".."); - rtems_test_assert (status == 0); - - rv = snprintf (path01, sizeof(path01), "%s/%s", dir02, name01); - rtems_test_assert (rv < sizeof(path01)); - EXPECT_ERROR (EACCES, rename, path01, path02); - - /* - * The new argument points to a file in a directory with execute access and - * the old argument points to another file on a directory without execute access. - */ - - EXPECT_ERROR (EACCES, rename, path02, path01); - /* * Clear directory */ - - EXPECT_EQUAL (0, unlink, path01); - status = chmod (dir01, mode); rtems_test_assert (status == 0); @@ -752,135 +587,6 @@ static void rename_search_permission_test (void) EXPECT_EQUAL (0, unlink, path01); EXPECT_EQUAL (0, unlink, path02); EXPECT_EQUAL (0, rmdir, dir01); - EXPECT_EQUAL (0, rmdir, dir02); - - /* - * Go back to parent directory - */ - - status = chdir (".."); - rtems_test_assert (status == 0); - - /* - * Remove test directory - */ - - status = rmdir (wd); - rtems_test_assert (status == 0); -} - -static void test_permission03 (void) -{ - int fd; - int status; - int rv; - - const char *name01 = "name01"; - const char *name02 = "name02"; - - const char *dir01 = "dir01"; - - char path01[30]; - - mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; - const char *wd = __func__; - - /* - * Create a new directory and change the current directory to this - */ - - status = mkdir (wd, mode); - rtems_test_assert (status == 0); - status = chdir (wd); - rtems_test_assert (status == 0); - - /* - * The new argument points to a file and - * the old argument points to another file on a directory with S_ISVTX. - */ - - puts ("\nRename files within directories protected with S_ISVTX\n"); - - status = mkdir (dir01, mode | S_ISVTX); - rtems_test_assert (status == 0); - - rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, name01); - rtems_test_assert (rv < sizeof(path01)); - fd = creat (path01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - fd = creat (name02, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - status = chown (path01, 65534, -1); - rtems_test_assert (status == 0); - - status = chown (dir01, 65534, -1); - rtems_test_assert (status == 0); - - EXPECT_EQUAL (-1, rename, path01, name02); - - puts("Testing errno for EPERM or EACCES"); - - if(errno == EPERM || errno == EACCES) - FS_PASS (); - else - FS_FAIL (); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, unlink, path01); - EXPECT_EQUAL (0, unlink, name02); - EXPECT_EQUAL (0, rmdir, dir01); - - /* - * The new argument points to a file on a directory with S_ISVTX and - * the old argument points to a file outside that directory. - */ - - status = mkdir (dir01, mode | S_ISVTX); - rtems_test_assert (status == 0); - - rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, name01); - rtems_test_assert (rv < sizeof(path01)); - fd = creat (path01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - fd = creat (name02, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - status = chown (path01, 65534, -1); - rtems_test_assert (status == 0); - - status = chown (dir01, 65534, -1); - rtems_test_assert (status == 0); - - EXPECT_EQUAL (-1, rename, name02, path01); - - puts("Testing errno for EPERM or EACCES"); - - if(errno == EPERM || errno == EACCES) - FS_PASS (); - else - FS_FAIL (); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, unlink, path01); - EXPECT_EQUAL (0, unlink, name02); - EXPECT_EQUAL (0, rmdir, dir01); /* * Go back to parent directory @@ -902,8 +608,6 @@ void test(void ) umask_test01(); test_permission01(); test_permission02(); - test_permission03(); root_test(); - rename_write_permission_test(); rename_search_permission_test(); } diff --git a/testsuites/fstests/fsrdwr/init.c b/testsuites/fstests/fsrdwr/init.c index aa7ccdb97f..16dbd62563 100644 --- a/testsuites/fstests/fsrdwr/init.c +++ b/testsuites/fstests/fsrdwr/init.c @@ -46,6 +46,7 @@ #include const char rtems_test_name[] = "FSRDWR " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; static const mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; diff --git a/testsuites/fstests/fsrename/test.c b/testsuites/fstests/fsrename/test.c index a05aa01409..e3bd0a619a 100644 --- a/testsuites/fstests/fsrename/test.c +++ b/testsuites/fstests/fsrename/test.c @@ -44,6 +44,7 @@ #include const char rtems_test_name[] = "FSRENAME " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; static void rename_file_twice_test (void) { @@ -108,68 +109,12 @@ static void rename_opened_file_test (void) EXPECT_EQUAL (0, unlink, name02); } -static void same_file_test (void) -{ - int fd; - int status; - - const char *name01 = "name01"; - - mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; - const char *wd = __func__; - - /* - * Create a new directory and change the current directory to this - */ - - status = mkdir (wd, mode); - rtems_test_assert (status == 0); - status = chdir (wd); - rtems_test_assert (status == 0); - - /* - * The new argument points to a file and - * the old argument points to the same file on the same directory. - */ - - puts ("\nRename file with itself\n"); - - fd = creat (name01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - EXPECT_EQUAL (0, rename, name01, name01); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, unlink, name01); - - /* - * Go back to parent directory - */ - - status = chdir (".."); - rtems_test_assert (status == 0); - - /* - * Remove test directory - */ - - status = rmdir (wd); - rtems_test_assert (status == 0); -} - static void directory_test (void) { int fd; int status; int rv; - int i; - const char *name01 = "name01"; const char *name02 = "name02"; const char *dir01 = "dir01"; @@ -177,15 +122,9 @@ static void directory_test (void) char path01[30]; - char link_name[10]; - mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; const char *wd = __func__; - struct stat statbuf; - - long LINK_MAX_val; - /* * Create a new directory and change the current directory to this */ @@ -195,78 +134,6 @@ static void directory_test (void) status = chdir (wd); rtems_test_assert (status == 0); - /* - * The new argument points to a file and - * the old argument points to a directory. - */ - - puts ("\nRename directory with file\n"); - - fd = creat (name01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - status = mkdir (dir01, mode); - rtems_test_assert (status == 0); - - EXPECT_ERROR (ENOTDIR, rename, dir01, name01); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, unlink, name01); - EXPECT_EQUAL (0, rmdir, dir01); - - /* - * The new argument points to a directory and - * the old argument points to a file. - */ - - puts ("\nRename file with directory\n"); - - fd = creat (name01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - status = mkdir (dir01, mode); - rtems_test_assert (status == 0); - - EXPECT_ERROR (EISDIR, rename, name01, dir01); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, unlink, name01); - EXPECT_EQUAL (0, rmdir, dir01); - - /* - * The new argument points to an empty directory and - * the old argument points to an ancestor directory of new. - */ - - puts ("\nRename directory with ancestor directory\n"); - - status = mkdir (dir02, mode); - rtems_test_assert (status == 0); - - rv = snprintf (path01, sizeof(path01), "%s/%s", dir02, dir01); - rtems_test_assert (rv < sizeof(path01)); - status = mkdir (path01, mode); - rtems_test_assert (status == 0); - - EXPECT_ERROR (EINVAL, rename, dir02, path01); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, rmdir, path01); - EXPECT_EQUAL (0, rmdir, dir02); - /* * The new argument points to an empty directory and * the old argument points to a non empty directory. @@ -291,10 +158,11 @@ static void directory_test (void) puts("Testing errno for EEXIST or ENOTEMPTY"); - if(errno == EEXIST || errno == ENOTEMPTY) + if (errno == EEXIST || errno == ENOTEMPTY) { FS_PASS (); - else + } else { FS_FAIL (); + } /* * Clear directory @@ -304,75 +172,6 @@ static void directory_test (void) EXPECT_EQUAL (0, rmdir, dir01); EXPECT_EQUAL (0, rmdir, dir02); - /* - * The new argument points to an empty directory and - * the old argument points to other empty directory. - */ - - puts ("\nRename empty directory with another empty directory\n"); - - status = mkdir (dir01, mode); - rtems_test_assert (status == 0); - - status = mkdir (dir02, mode); - rtems_test_assert (status == 0); - - EXPECT_EQUAL (0, rename, dir01, dir02); - - /* - * Clear directory - */ - - EXPECT_EQUAL (-1, rmdir, dir01); - EXPECT_EQUAL (0, rmdir, dir02); - - /* - * The new argument points to a non existant directory and - * the old argument points to an existant directory at LINK_MAX. - */ - - status = mkdir (dir01, mode); - rtems_test_assert (status == 0); - - LINK_MAX_val = pathconf (dir01, _PC_LINK_MAX); - rtems_test_assert (LINK_MAX_val >= 0); - - status = stat (dir01, &statbuf); - rtems_test_assert (status == 0); - - for(i = statbuf.st_nlink; i < LINK_MAX_val; i++) - { - rv = snprintf (link_name, sizeof(link_name), "%s/%d", dir01, i); - rtems_test_assert (rv < sizeof(link_name)); - - status = mkdir (link_name, mode); - rtems_test_assert (status == 0); - } - - status = mkdir (dir02, mode); - rtems_test_assert (status == 0); - - rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, dir01); - rtems_test_assert (rv < sizeof(path01)); - EXPECT_ERROR (EMLINK, rename, dir02, path01); - - /* - * Clear directory - */ - - for(i = statbuf.st_nlink; i < LINK_MAX_val; i++) - { - rv = snprintf (link_name, sizeof(link_name), "%s/%d", dir01, i); - rtems_test_assert (rv < sizeof(link_name)); - - status = rmdir (link_name); - rtems_test_assert (status == 0); - } - - EXPECT_EQUAL (-1, rmdir, path01); - EXPECT_EQUAL (0, rmdir, dir02); - EXPECT_EQUAL (0, rmdir, dir01); - /* * Go back to parent directory */ @@ -402,8 +201,7 @@ static void arg_test (void) mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; const char *wd = __func__; - - char filename[NAME_MAX + 2]; + char path01[20]; /* @@ -436,25 +234,6 @@ static void arg_test (void) EXPECT_EQUAL (-1, unlink, name01); EXPECT_EQUAL (0, unlink, name02); - /* - * The new argument points to a file and - * the old argument points to a non existant file. - */ - - fd = creat (name01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - EXPECT_ERROR (ENOENT, rename, name02, name01); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, unlink, name01); - EXPECT_EQUAL (-1, unlink, name02); - /* * The new argument points to a non existant file and * the old argument points to a file where a component of the @@ -496,173 +275,6 @@ static void arg_test (void) EXPECT_EQUAL (-1, rmdir, dir01); EXPECT_EQUAL (0, rmdir, dir02); - /* - * The new argument is a name bigger than NAME_MAX and - * the old argument points to a file. - */ - - puts ("\nRename file with a name size exceeding NAME_MAX\n"); - - fd = creat (name01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - /* Generate string with NAME_MAX + 1 length */ - memset(filename, 'a', NAME_MAX + 1); - filename[NAME_MAX + 1] = '\0'; - - EXPECT_ERROR (ENAMETOOLONG, rename, name01, filename); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, unlink, name01); - EXPECT_EQUAL (-1, unlink, filename); - - /* - * Go back to parent directory - */ - - status = chdir (".."); - rtems_test_assert (status == 0); - - /* - * Remove test directory - */ - - status = rmdir (wd); - rtems_test_assert (status == 0); -} - -static void arg_format_test (void) -{ - int fd; - int status; - const char *name01 = "name01"; - - const char *dir01 = "dir01"; - - mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; - const char *wd = __func__; - - /* - * Create a new directory and change the current directory to this - */ - - status = mkdir (wd, mode); - rtems_test_assert (status == 0); - status = chdir (wd); - rtems_test_assert (status == 0); - - /* - * The new argument points to a directory and - * the old argument points to current directory. - */ - - puts ("\nRename directory with current directory\n"); - - status = mkdir (dir01, mode); - rtems_test_assert (status == 0); - - EXPECT_EQUAL (-1, rename, "." , dir01); - - puts("Testing errno for EINVAL or EBUSY"); - - if(errno == EINVAL || errno == EBUSY) - FS_PASS (); - else - FS_FAIL (); - - /* - * The new argument points to current directory and - * the old argument points to a directory. - */ - - EXPECT_EQUAL (-1, rename, dir01, "."); - - puts("Testing errno for EINVAL or EBUSY"); - - if(errno == EINVAL || errno == EBUSY) - FS_PASS (); - else - FS_FAIL (); - - /* - * The new argument points to a directory and - * the old argument points to previous directory. - */ - - puts ("\nRename directory with previous directory\n"); - - EXPECT_EQUAL (-1, rename, ".." , dir01); - - puts("Testing errno for EINVAL or EBUSY"); - - if(errno == EINVAL || errno == EBUSY) - FS_PASS (); - else - FS_FAIL (); - - /* - * The new argument points to previous directory and - * the old argument points to a directory. - */ - - EXPECT_EQUAL (-1, rename, dir01, ".."); - - puts("Testing errno for EINVAL or EBUSY"); - - if(errno == EINVAL || errno == EBUSY) - FS_PASS (); - else - FS_FAIL (); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, rmdir, dir01); - - /* - * The new argument points to a file and - * the old argument is an empty string. - */ - - puts("\nTesting empty filepaths\n"); - - fd = creat (name01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - EXPECT_ERROR (ENOENT, rename, name01, ""); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, unlink, name01); - - /* - * The new argument is an empty string and - * the old argument points to a file. - */ - - fd = creat (name01, mode); - rtems_test_assert (fd >= 0); - status = close (fd); - rtems_test_assert (status == 0); - - EXPECT_ERROR (ENOENT, rename, "", name01); - - /* - * Clear directory - */ - - EXPECT_EQUAL (0, unlink, name01); - /* * Go back to parent directory */ @@ -744,10 +356,8 @@ static void filesystem_test (void) void test (void) { rename_file_twice_test (); - same_file_test (); directory_test (); rename_opened_file_test (); arg_test (); - arg_format_test (); filesystem_test (); } diff --git a/testsuites/fstests/fsrenameexisting/test.c b/testsuites/fstests/fsrenameexisting/test.c new file mode 100644 index 0000000000..ac62cae939 --- /dev/null +++ b/testsuites/fstests/fsrenameexisting/test.c @@ -0,0 +1,465 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/* + * COPYRIGHT (c) 1989-2011. + * 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 + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "fstest.h" +#include "fs_config.h" +#include + +const char rtems_test_name[] = "FSRENAMEEXISTING " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; + +static void rename_error (void) +{ + + int fd; + int status; + char *name01 = "name01"; + char *name02 = "name02"; + char *name03 = "name03"; + char *nonexistence = "name04"; + + char name[20]; + + mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; + const char *wd = __func__; + + /* + *Create a new directory and change the current directory to this + */ + + status = mkdir (wd, mode); + rtems_test_assert (status == 0); + status = chdir (wd); + rtems_test_assert (status == 0); + + + /* + * Create a new directory and a new directory in it + */ + + status = mkdir (name01, mode); + rtems_test_assert (status == 0); + status = mkdir (name02, mode); + rtems_test_assert (status == 0); + sprintf (name, "%s/%s", name01, name03); + status = mkdir (name, mode); + rtems_test_assert (status == 0); + + /* + * The new directory pathname contains a path prefix + * that names the old directory. + */ + EXPECT_ERROR (EINVAL, rename, name01, name); + /* + * The new argument points to a directory and + * the old argument points to a file that is not a directory. + */ + fd = creat (name03, mode); + status = close (fd); + rtems_test_assert (status == 0); + EXPECT_ERROR (EISDIR, rename, name03, name02); + + /* + * The link named by old does not name an existing file, + * or either old or new points to an empty string. + */ + + EXPECT_ERROR (ENOENT, rename, nonexistence, name01); + EXPECT_ERROR (ENOENT, rename, "", name01); + + /* + * A component of either path prefix is not a directory; + * or the old argument names a directory and new argument names + * a non-directory file. + */ + + sprintf (name, "%s/%s", name03, name01); + EXPECT_ERROR (ENOTDIR, rename, name, name03); + EXPECT_ERROR (ENOTDIR, rename, name02, name03); + + /* + * Go back to parent directory + */ + status = chdir (".."); + rtems_test_assert (status == 0); +} + +static void same_file_test (void) +{ + int fd; + int status; + + const char *name01 = "name01"; + + mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; + const char *wd = __func__; + + /* + * Create a new directory and change the current directory to this + */ + + status = mkdir (wd, mode); + rtems_test_assert (status == 0); + status = chdir (wd); + rtems_test_assert (status == 0); + + /* + * The new argument points to a file and + * the old argument points to the same file on the same directory. + */ + + puts ("\nRename file with itself\n"); + + fd = creat (name01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + EXPECT_EQUAL (0, rename, name01, name01); + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, unlink, name01); + + /* + * Go back to parent directory + */ + + status = chdir (".."); + rtems_test_assert (status == 0); + + /* + * Remove test directory + */ + + status = rmdir (wd); + rtems_test_assert (status == 0); +} + + +static void directory_test (void) +{ + int fd; + int status; + int rv; + + const char *name01 = "name01"; + + const char *dir01 = "dir01"; + const char *dir02 = "dir02"; + + char path01[30]; + + mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; + const char *wd = __func__; + + /* + * Create a new directory and change the current directory to this + */ + + status = mkdir (wd, mode); + rtems_test_assert (status == 0); + status = chdir (wd); + rtems_test_assert (status == 0); + + /* + * The new argument points to a file and + * the old argument points to a directory. + */ + + puts ("\nRename directory with file\n"); + + fd = creat (name01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + status = mkdir (dir01, mode); + rtems_test_assert (status == 0); + + EXPECT_ERROR (ENOTDIR, rename, dir01, name01); + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, unlink, name01); + EXPECT_EQUAL (0, rmdir, dir01); + + /* + * The new argument points to a directory and + * the old argument points to a file. + */ + + puts ("\nRename file with directory\n"); + + fd = creat (name01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + status = mkdir (dir01, mode); + rtems_test_assert (status == 0); + + EXPECT_ERROR (EISDIR, rename, name01, dir01); + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, unlink, name01); + EXPECT_EQUAL (0, rmdir, dir01); + + /* + * The new argument points to an empty directory and + * the old argument points to an ancestor directory of new. + */ + + puts ("\nRename directory with ancestor directory\n"); + + status = mkdir (dir02, mode); + rtems_test_assert (status == 0); + + rv = snprintf (path01, sizeof(path01), "%s/%s", dir02, dir01); + rtems_test_assert (rv < sizeof(path01)); + status = mkdir (path01, mode); + rtems_test_assert (status == 0); + + EXPECT_ERROR (EINVAL, rename, dir02, path01); + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, rmdir, path01); + EXPECT_EQUAL (0, rmdir, dir02); + + /* + * The new argument points to an empty directory and + * the old argument points to other empty directory. + */ + + puts ("\nRename empty directory with another empty directory\n"); + + status = mkdir (dir01, mode); + rtems_test_assert (status == 0); + + status = mkdir (dir02, mode); + rtems_test_assert (status == 0); + + EXPECT_EQUAL (0, rename, dir01, dir02); + + /* + * Clear directory + */ + + EXPECT_EQUAL (-1, rmdir, dir01); + EXPECT_EQUAL (0, rmdir, dir02); + + /* + * Go back to parent directory + */ + + status = chdir (".."); + rtems_test_assert (status == 0); + + /* + * Remove test directory + */ + + status = rmdir (wd); + rtems_test_assert (status == 0); +} + +static void arg_format_test (void) +{ + int fd; + int status; + const char *name01 = "name01"; + + const char *dir01 = "dir01"; + + mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; + const char *wd = __func__; + + /* + * Create a new directory and change the current directory to this + */ + + status = mkdir (wd, mode); + rtems_test_assert (status == 0); + status = chdir (wd); + rtems_test_assert (status == 0); + + /* + * The new argument points to a directory and + * the old argument points to current directory. + */ + + puts ("\nRename directory with current directory\n"); + + status = mkdir (dir01, mode); + rtems_test_assert (status == 0); + + EXPECT_EQUAL (-1, rename, "." , dir01); + + puts("Testing errno for EINVAL or EBUSY"); + + if (errno == EINVAL || errno == EBUSY) { + FS_PASS (); + } else { + FS_FAIL (); + } + + /* + * The new argument points to current directory and + * the old argument points to a directory. + */ + + EXPECT_EQUAL (-1, rename, dir01, "."); + + puts("Testing errno for EINVAL or EBUSY"); + + if (errno == EINVAL || errno == EBUSY) { + FS_PASS (); + } else { + FS_FAIL (); + } + + /* + * The new argument points to a directory and + * the old argument points to previous directory. + */ + + puts ("\nRename directory with previous directory\n"); + + EXPECT_EQUAL (-1, rename, ".." , dir01); + + puts("Testing errno for EINVAL or EBUSY"); + + if (errno == EINVAL || errno == EBUSY) { + FS_PASS (); + } else { + FS_FAIL (); + } + + /* + * The new argument points to previous directory and + * the old argument points to a directory. + */ + + EXPECT_EQUAL (-1, rename, dir01, ".."); + + puts("Testing errno for EINVAL or EBUSY"); + + if (errno == EINVAL || errno == EBUSY) { + FS_PASS (); + } else { + FS_FAIL (); + } + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, rmdir, dir01); + + /* + * The new argument points to a file and + * the old argument is an empty string. + */ + + puts("\nTesting empty filepaths\n"); + + fd = creat (name01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + EXPECT_ERROR (ENOENT, rename, name01, ""); + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, unlink, name01); + + /* + * The new argument is an empty string and + * the old argument points to a file. + */ + + fd = creat (name01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + EXPECT_ERROR (ENOENT, rename, "", name01); + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, unlink, name01); + + /* + * Go back to parent directory + */ + + status = chdir (".."); + rtems_test_assert (status == 0); + + /* + * Remove test directory + */ + + status = rmdir (wd); + rtems_test_assert (status == 0); +} + +void test (void) +{ + rename_error (); + same_file_test (); + directory_test (); + arg_format_test (); +} \ No newline at end of file diff --git a/testsuites/fstests/fsrenamelongname/test.c b/testsuites/fstests/fsrenamelongname/test.c new file mode 100644 index 0000000000..9be34fa08c --- /dev/null +++ b/testsuites/fstests/fsrenamelongname/test.c @@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/* + * COPYRIGHT (c) 1989-2011. + * 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 + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fstest.h" +#include "fs_config.h" +#include + +const char rtems_test_name[] = "FSRENAMELONGNAME " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; + +void test (void) +{ + int fd; + int status; + + const char *name01 = "name01"; + + mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; + const char *wd = __func__; + + char filename[NAME_MAX + 2]; + + /* + * Create a new directory and change the current directory to this + */ + + status = mkdir (wd, mode); + rtems_test_assert (status == 0); + status = chdir (wd); + rtems_test_assert (status == 0); + + /* + * The new argument is a name bigger than NAME_MAX and + * the old argument points to a file. + */ + + puts ("\nRename file with a name size exceeding NAME_MAX\n"); + + fd = creat (name01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + /* Generate string with NAME_MAX + 1 length */ + memset(filename, 'a', NAME_MAX + 1); + filename[NAME_MAX + 1] = '\0'; + + EXPECT_ERROR (ENAMETOOLONG, rename, name01, filename); + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, unlink, name01); + EXPECT_EQUAL (-1, unlink, filename); + + /* + * Go back to parent directory + */ + + status = chdir (".."); + rtems_test_assert (status == 0); + + /* + * Remove test directory + */ + + status = rmdir (wd); + rtems_test_assert (status == 0); +} diff --git a/testsuites/fstests/fsrenamemaxlinks/test.c b/testsuites/fstests/fsrenamemaxlinks/test.c new file mode 100644 index 0000000000..0bc2dec02f --- /dev/null +++ b/testsuites/fstests/fsrenamemaxlinks/test.c @@ -0,0 +1,137 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/* + * COPYRIGHT (c) 1989-2011. + * 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 + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "fstest.h" +#include "fs_config.h" +#include + +const char rtems_test_name[] = "FSRENAMEMAXLINKS " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; + +void test (void) +{ + int status; + int rv; + int i; + + const char *dir01 = "dir01"; + const char *dir02 = "dir02"; + + char path01[30]; + + char link_name[10]; + + mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; + const char *wd = __func__; + + struct stat statbuf; + + long LINK_MAX_val; + + /* + * Create a new directory and change the current directory to this + */ + + status = mkdir (wd, mode); + rtems_test_assert (status == 0); + status = chdir (wd); + rtems_test_assert (status == 0); + + /* + * The new argument points to a non existant directory and + * the old argument points to an existant directory at LINK_MAX. + */ + + status = mkdir (dir01, mode); + rtems_test_assert (status == 0); + + LINK_MAX_val = pathconf (dir01, _PC_LINK_MAX); + rtems_test_assert (LINK_MAX_val >= 0); + + status = stat (dir01, &statbuf); + rtems_test_assert (status == 0); + + for(i = statbuf.st_nlink; i < LINK_MAX_val; i++) + { + rv = snprintf (link_name, sizeof(link_name), "%s/%d", dir01, i); + rtems_test_assert (rv < sizeof(link_name)); + + status = mkdir (link_name, mode); + rtems_test_assert (status == 0); + } + + status = mkdir (dir02, mode); + rtems_test_assert (status == 0); + + rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, dir01); + rtems_test_assert (rv < sizeof(path01)); + EXPECT_ERROR (EMLINK, rename, dir02, path01); + + /* + * Clear directory + */ + + for(i = statbuf.st_nlink; i < LINK_MAX_val; i++) + { + rv = snprintf (link_name, sizeof(link_name), "%s/%d", dir01, i); + rtems_test_assert (rv < sizeof(link_name)); + + status = rmdir (link_name); + rtems_test_assert (status == 0); + } + + EXPECT_EQUAL (-1, rmdir, path01); + EXPECT_EQUAL (0, rmdir, dir02); + EXPECT_EQUAL (0, rmdir, dir01); + + /* + * Go back to parent directory + */ + + status = chdir (".."); + rtems_test_assert (status == 0); + + /* + * Remove test directory + */ + + status = rmdir (wd); + rtems_test_assert (status == 0); +} diff --git a/testsuites/fstests/fsrenamepermexisting/test.c b/testsuites/fstests/fsrenamepermexisting/test.c new file mode 100644 index 0000000000..587159aee0 --- /dev/null +++ b/testsuites/fstests/fsrenamepermexisting/test.c @@ -0,0 +1,428 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/* + * COPYRIGHT (c) 1989-2011. + * 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 + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fstest.h" +#include "fs_config.h" +#include + +const char rtems_test_name[] = "FSRENAMEPERMEXISTING " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; + +static void rename_write_permission_test (void) +{ + int fd; + int status; + int rv; + + const char *name01 = "name01"; + const char *name02 = "name02"; + + const char *dir01 = "dir01"; + const char *dir02 = "dir02"; + + char path01[20]; + + mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; + mode_t no_write_access = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP + | S_IROTH | S_IXOTH; + + const char *wd = __func__; + + /* + * Create a new directory and change the current directory to this + */ + + status = mkdir (wd, mode); + rtems_test_assert (status == 0); + status = chdir (wd); + rtems_test_assert (status == 0); + + /* + * The new argument points to a file and + * the old argument points to another file, + * both inside a directory with no write permission. + */ + + puts ("\nRename two files on a directory with no write permission \n"); + + status = mkdir (dir01, mode); + rtems_test_assert (status == 0); + + status = chdir (dir01); + rtems_test_assert (status == 0); + + fd = creat (name01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + fd = creat (name02, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + status = chmod (".", no_write_access); + rtems_test_assert (status == 0); + + EXPECT_ERROR (EACCES, rename, name01 , name02); + + status = chdir (".."); + rtems_test_assert (status == 0); + + /* + * The new argument points to a file in a directory with no write access and + * the old argument points to another file on a directory with write access. + */ + + puts ("\nRename file between two directories, with and without write access\n"); + + status = mkdir (dir02, mode); + rtems_test_assert (status == 0); + + status = chdir (dir02); + rtems_test_assert (status == 0); + + fd = creat (name01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + rv = snprintf (path01, sizeof(path01), "../%s/%s", dir01, name02); + rtems_test_assert (rv < sizeof(path01)); + EXPECT_ERROR (EACCES, rename, name01, path01); + + /* + * The new argument points to a file in a directory with write access and + * the old argument points to another file on a directory without write access. + */ + + EXPECT_ERROR (EACCES, rename, path01, name01); + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, unlink, name01); + + rv = snprintf (path01, sizeof(path01), "../%s", dir01); + rtems_test_assert (rv < sizeof(path01)); + status = chmod (path01, mode); + rtems_test_assert (status == 0); + + rv = snprintf (path01, sizeof(path01), "../%s/%s", dir01, name01); + rtems_test_assert (rv < sizeof(path01)); + EXPECT_EQUAL (0, unlink, path01); + + rv = snprintf (path01, sizeof(path01), "../%s/%s", dir01, name02); + rtems_test_assert (rv < sizeof(path01)); + EXPECT_EQUAL (0, unlink, path01); + + status = chdir (".."); + rtems_test_assert (status == 0); + + EXPECT_EQUAL (0, rmdir, dir01); + EXPECT_EQUAL (0, rmdir, dir02); + + /* + * Go back to parent directory + */ + + status = chdir (".."); + rtems_test_assert (status == 0); + + /* + * Remove test directory + */ + + status = rmdir (wd); + rtems_test_assert (status == 0); +} + +static void rename_search_permission_test (void) +{ + int fd; + int status; + int rv; + + const char *name01 = "name01"; + const char *name02 = "name02"; + + const char *dir01 = "dir01"; + const char *dir02 = "dir02"; + + char path01[20]; + char path02[20]; + + mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; + mode_t no_execute_access = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP + | S_IROTH | S_IWOTH; + + const char *wd = __func__; + + /* + * Create a new directory and change the current directory to this + */ + + status = mkdir (wd, mode); + rtems_test_assert (status == 0); + status = chdir (wd); + rtems_test_assert (status == 0); + + /* + * The new argument points to a file in a directory with no execute access and + * the old argument points to another file on a directory with execute access. + */ + + puts ("\nRename file between two directories, with and without execute access\n"); + + status = mkdir (dir01, mode); + rtems_test_assert (status == 0); + + rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, name01); + rtems_test_assert (rv < sizeof(path01)); + fd = creat (path01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + rv = snprintf (path02, sizeof(path02), "%s/%s", dir01, name02); + rtems_test_assert (rv < sizeof(path02)); + fd = creat (path02, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + status = chmod (dir01, no_execute_access); + rtems_test_assert (status == 0); + + status = mkdir (dir02, mode); + rtems_test_assert (status == 0); + + status = chdir (dir02); + rtems_test_assert (status == 0); + + fd = creat (name01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + status = chdir (".."); + rtems_test_assert (status == 0); + + rv = snprintf (path01, sizeof(path01), "%s/%s", dir02, name01); + rtems_test_assert (rv < sizeof(path01)); + EXPECT_ERROR (EACCES, rename, path01, path02); + + /* + * The new argument points to a file in a directory with execute access and + * the old argument points to another file on a directory without execute access. + */ + + EXPECT_ERROR (EACCES, rename, path02, path01); + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, unlink, path01); + + status = chmod (dir01, mode); + rtems_test_assert (status == 0); + + rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, name01); + rtems_test_assert (rv < sizeof(path01)); + EXPECT_EQUAL (0, unlink, path01); + EXPECT_EQUAL (0, unlink, path02); + EXPECT_EQUAL (0, rmdir, dir01); + EXPECT_EQUAL (0, rmdir, dir02); + + /* + * Go back to parent directory + */ + + status = chdir (".."); + rtems_test_assert (status == 0); + + /* + * Remove test directory + */ + + status = rmdir (wd); + rtems_test_assert (status == 0); +} + +static void rename_permission03 (void) +{ + int fd; + int status; + int rv; + + const char *name01 = "name01"; + const char *name02 = "name02"; + + const char *dir01 = "dir01"; + + char path01[30]; + + mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; + const char *wd = __func__; + + /* + * Create a new directory and change the current directory to this + */ + + status = mkdir (wd, mode); + rtems_test_assert (status == 0); + status = chdir (wd); + rtems_test_assert (status == 0); + + /* + * The new argument points to a file and + * the old argument points to another file on a directory with S_ISVTX. + */ + + puts ("\nRename files within directories protected with S_ISVTX\n"); + + status = mkdir (dir01, mode | S_ISVTX); + rtems_test_assert (status == 0); + + rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, name01); + rtems_test_assert (rv < sizeof(path01)); + fd = creat (path01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + fd = creat (name02, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + status = chown (path01, 65534, -1); + rtems_test_assert (status == 0); + + status = chown (dir01, 65534, -1); + rtems_test_assert (status == 0); + + EXPECT_EQUAL (-1, rename, path01, name02); + + puts("Testing errno for EPERM or EACCES"); + + if (errno == EPERM || errno == EACCES) { + FS_PASS (); + } else { + FS_FAIL (); + } + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, unlink, path01); + EXPECT_EQUAL (0, unlink, name02); + EXPECT_EQUAL (0, rmdir, dir01); + + /* + * The new argument points to a file on a directory with S_ISVTX and + * the old argument points to a file outside that directory. + */ + + status = mkdir (dir01, mode | S_ISVTX); + rtems_test_assert (status == 0); + + rv = snprintf (path01, sizeof(path01), "%s/%s", dir01, name01); + rtems_test_assert (rv < sizeof(path01)); + fd = creat (path01, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + fd = creat (name02, mode); + rtems_test_assert (fd >= 0); + status = close (fd); + rtems_test_assert (status == 0); + + status = chown (path01, 65534, -1); + rtems_test_assert (status == 0); + + status = chown (dir01, 65534, -1); + rtems_test_assert (status == 0); + + EXPECT_EQUAL (-1, rename, name02, path01); + + puts("Testing errno for EPERM or EACCES"); + + if (errno == EPERM || errno == EACCES) { + FS_PASS (); + } else { + FS_FAIL (); + } + + /* + * Clear directory + */ + + EXPECT_EQUAL (0, unlink, path01); + EXPECT_EQUAL (0, unlink, name02); + EXPECT_EQUAL (0, rmdir, dir01); + + /* + * Go back to parent directory + */ + + status = chdir (".."); + rtems_test_assert (status == 0); + + /* + * Remove test directory + */ + + status = rmdir (wd); + rtems_test_assert (status == 0); +} + +void test (void) +{ + rename_write_permission_test (); + rename_search_permission_test (); + rename_permission03 (); +} diff --git a/testsuites/fstests/fsrfsbitmap01/test.c b/testsuites/fstests/fsrfsbitmap01/test.c index d6dddae96f..5129fc17bc 100644 --- a/testsuites/fstests/fsrfsbitmap01/test.c +++ b/testsuites/fstests/fsrfsbitmap01/test.c @@ -49,6 +49,7 @@ #include const char rtems_test_name[] = "FSRFSBITMAP 1"; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; #define rtems_rfs_exit_on_error(_rc, _r, _c, _b) \ if ((_rc > 0) || _r) { free (_b); rtems_rfs_bitmap_close (_c); return; } diff --git a/testsuites/fstests/fsrmdirparent/test.c b/testsuites/fstests/fsrmdirparent/test.c new file mode 100644 index 0000000000..541a8f1b71 --- /dev/null +++ b/testsuites/fstests/fsrmdirparent/test.c @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/* + * COPYRIGHT (c) 1989-2011. + * 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 + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include + +#include "fstest.h" +#include "fs_config.h" +#include + +const char rtems_test_name[] = "FSRMDIRPARENT " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; + +static void rmdir_error (void) +{ + int status; + mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; + + const char *wd = __func__; + + /* + * Create a new directory and change the current directory to this + */ + status = mkdir (wd, mode); + rtems_test_assert (status == 0); + status = chdir (wd); + rtems_test_assert (status == 0); + + /* + * Create a new directory for test + */ + status = mkdir ("tmp", mode); + rtems_test_assert (status == 0); + + /* + * The path argument names a directory that is not an empty directory, + * or there are hard links to the directory other than + * dot or a single entry in dot-dot. + */ + + EXPECT_ERROR (ENOTEMPTY, rmdir, ".."); + + /* + * Go back to parent directory + */ + status = chdir (".."); + rtems_test_assert (status == 0); + + +} + +void test (void) +{ + rmdir_error (); +} diff --git a/testsuites/fstests/fsscandir01/init.c b/testsuites/fstests/fsscandir01/init.c index ce9c100bdf..23ee9dc278 100644 --- a/testsuites/fstests/fsscandir01/init.c +++ b/testsuites/fstests/fsscandir01/init.c @@ -43,6 +43,7 @@ #include "fs_config.h" const char rtems_test_name[] = "FSSCANDIR " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; #define FILE_NAME "aaa" diff --git a/testsuites/fstests/fsstatvfs/test.c b/testsuites/fstests/fsstatvfs/test.c index e5c4b94a26..4e80cc6dd1 100644 --- a/testsuites/fstests/fsstatvfs/test.c +++ b/testsuites/fstests/fsstatvfs/test.c @@ -39,6 +39,7 @@ #include const char rtems_test_name[] = "FSSTATVFS " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; static void statvfs_validate(struct statvfs *stat) { diff --git a/testsuites/fstests/fssymlink/test.c b/testsuites/fstests/fssymlink/test.c index a6b1cad84b..e0e608c9ae 100644 --- a/testsuites/fstests/fssymlink/test.c +++ b/testsuites/fstests/fssymlink/test.c @@ -45,10 +45,8 @@ #include "fs_config.h" #include -//#include "fstest_support.h" -//#include - const char rtems_test_name[] = "FSSYMLINK " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; /* * Test the function of symlink @@ -232,10 +230,11 @@ static void symlink_rename_test (void) puts ("Testing if name02 is now a symlink"); - if(S_ISLNK(statbuf.st_mode) != 0) + if (S_ISLNK(statbuf.st_mode) != 0) { FS_PASS (); - else + } else { FS_FAIL (); + } /* * Clear directory @@ -270,10 +269,11 @@ static void symlink_rename_test (void) puts ("Testing that symlink01 is not a symlink"); - if(S_ISLNK(statbuf.st_mode) == 0) + if (S_ISLNK(statbuf.st_mode) == 0) { FS_PASS (); - else + } else { FS_FAIL (); + } /* * Clear directory diff --git a/testsuites/fstests/fstime/test.c b/testsuites/fstests/fstime/test.c index ab2c5d568b..6d626b84fc 100644 --- a/testsuites/fstests/fstime/test.c +++ b/testsuites/fstests/fstime/test.c @@ -47,6 +47,7 @@ #include const char rtems_test_name[] = "FSTIME " FILESYSTEM; +const RTEMS_TEST_STATE rtems_test_state = TEST_STATE; #else #include #define rtems_test_assert(x) assert(x) diff --git a/testsuites/fstests/support/fstest.h b/testsuites/fstests/support/fstest.h index 0f805359b3..2b3daa4d16 100644 --- a/testsuites/fstests/support/fstest.h +++ b/testsuites/fstests/support/fstest.h @@ -36,6 +36,7 @@ #define FS_PASS() do {puts("PASS");} while (0) #define FS_FAIL() do {\ printf( "FAIL %s: %d \n", __FILE__, __LINE__ );\ + fs_test_notify_failure(); \ } while (0) @@ -67,6 +68,8 @@ FS_FAIL();\ } while (0) + +void fs_test_notify_failure(void); void test(void); #define BASE_FOR_TEST "/mnt" diff --git a/testsuites/fstests/support/fstest_support.c b/testsuites/fstests/support/fstest_support.c index f56a77b4b1..0f4b4377a0 100644 --- a/testsuites/fstests/support/fstest_support.c +++ b/testsuites/fstests/support/fstest_support.c @@ -50,6 +50,15 @@ void *volatile prevent_compiler_optimizations; +static int fs_test_failed = 0; +extern const RTEMS_TEST_STATE rtems_test_state; + +void fs_test_notify_failure(void) +{ + fs_test_failed = 1; +} + + /* Break out of a chroot() environment in C */ static void break_out_of_chroot(void) { @@ -76,7 +85,7 @@ rtems_task Init( { int rc=0; - TEST_BEGIN(); + rtems_test_begin(rtems_test_name, rtems_test_state); puts( "Initializing filesystem " FILESYSTEM ); test_initialize_filesystem(); @@ -91,6 +100,6 @@ rtems_task Init( puts( "\n\nShutting down filesystem " FILESYSTEM ); test_shutdown_filesystem(); - TEST_END(); + if (!fs_test_failed) rtems_test_end(rtems_test_name); rtems_test_exit(0); }