selftests: gpio: gpio-aggregator: add a test case for _sysfs prefix reservation
authorKoichiro Den <koichiro.den@canonical.com>
Sat, 12 Apr 2025 15:01:19 +0000 (00:01 +0900)
committerBartosz Golaszewski <brgl@bgdev.pl>
Mon, 14 Apr 2025 20:30:01 +0000 (22:30 +0200)
The kernel doc for gpio-aggregator configfs interface, which was recently
added, states that users should not be able to create an aggregator with a
name prefixed by "_sysfs" via configfs. However, it was found that this
guard does not function as expected (thanks to Dan Carpenter for
identifying and fixing the issue).

Add a test case to verify the guard.

Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
Link: https://lore.kernel.org/r/20250412150119.1461023-1-koichiro.den@canonical.com
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
tools/testing/selftests/gpio/gpio-aggregator.sh

index f1bab62c4cd202106838841d6916e09c9167f025..9b6f80ad9f8ab71089d088bbe823c6fb5cd9d957 100755 (executable)
@@ -335,6 +335,10 @@ test "$(cat "$CONFIGFS_AGG_DIR/agg0/live")" = 0 || \
 agg_remove_line   agg0 line0
 agg_remove_chip   agg0
 
+echo "1.1.6. Can't instantiate a chip with _sysfs prefix"
+mkdir "$CONFIGFS_AGG_DIR/_sysfs" 2> /dev/null && fail "chip _sysfs unexpectedly created"
+mkdir "$CONFIGFS_AGG_DIR/_sysfs.foo" 2> /dev/null && fail "chip _sysfs.foo unexpectedly created"
+
 echo "1.2. Creation/deletion via sysfs"
 
 echo "1.2.1. Minimum creation/deletion"