generic: test idmapped mount circular mappings
[xfstests-dev.git] / tools / nextid
deleted file mode 120000 (symlink)
index 5c31d602abff9aee3006ca4fd8c028e68f8a235c..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-sort-group
\ No newline at end of file
new file mode 100755 (executable)
index 0000000000000000000000000000000000000000..9e31718c14c5e5d58da2be5afc5c0f05fcf518f2
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2015 Oracle.  All Rights Reserved.
+#
+# Compute the next available test id in a given test directory.
+
+if [ $# != 1 ] || [ "$1" = "--help" ] || [ ! -d "tests/$1/" ]; then
+       echo "Usage: $0 test_dir"
+       exit 1
+fi
+
+. ./common/test_names
+
+i=0
+eof=1
+
+while read found other_junk;
+do
+       i=$((i+1))
+       id=`printf "%03d" $i`
+       if [ "$id" != "$found" ]; then
+               eof=0
+               break
+       fi
+done < <(cd "tests/$1/" ; ../../tools/mkgroupfile | \
+        grep "^$VALID_TEST_NAME\>" | tr - ' ')
+
+if [ $eof -eq 1 ]; then
+   i=$((i+1))
+   id=`printf "%03d" $i`
+fi
+
+echo "$1/$id"