summaryrefslogtreecommitdiffstats
path: root/src/at/realpath.at
diff options
context:
space:
mode:
Diffstat (limited to 'src/at/realpath.at')
-rw-r--r--src/at/realpath.at86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/at/realpath.at b/src/at/realpath.at
new file mode 100644
index 0000000..2919c3e
--- /dev/null
+++ b/src/at/realpath.at
@@ -0,0 +1,86 @@
+AT_SETUP([dpkg-realpath options])
+AT_KEYWORDS([dpkg-realpath command-line])
+
+AT_CHECK([dpkg-realpath --version], [], [ignore])
+AT_CHECK([dpkg-realpath --help], [], [ignore])
+
+AT_CLEANUP
+
+AT_SETUP([dpkg-realpath path resolving])
+AT_KEYWORDS([dpkg-realpath canonicalize])
+
+mkdir -p aa/bb/cc
+mkdir -p zz/yy/xx
+mkdir -p usr/bin
+AT_DATA([aa/bb/cc/file], [])
+ln -sfT aa/bb/cc/file zz/yy/xx/symlink-rel
+ln -sfT /aa/bb/cc/file zz/yy/xx/symlink-abs
+AT_DATA([usr/bin/a-shell], [])
+ln -sfT /usr/bin/a-shell usr/bin/sh
+
+tmpdir="$(pwd)"
+export DPKG_ROOT=
+
+# Relative paths
+AT_CHECK_UNQUOTED([dpkg-realpath aa/bb/cc], [],
+[$tmpdir/aa/bb/cc
+])
+AT_CHECK_UNQUOTED([dpkg-realpath zz/yy/xx], [], [$tmpdir/zz/yy/xx
+])
+AT_CHECK_UNQUOTED([dpkg-realpath usr/bin], [], [$tmpdir/usr/bin
+])
+AT_CHECK_UNQUOTED([dpkg-realpath aa/bb/cc/file], [], [$tmpdir/aa/bb/cc/file
+])
+AT_CHECK_UNQUOTED([dpkg-realpath zz/yy/xx/symlink-rel], [],
+[$tmpdir/zz/yy/xx/aa/bb/cc/file
+])
+AT_CHECK([dpkg-realpath zz/yy/xx/symlink-abs], [], [/aa/bb/cc/file
+])
+AT_CHECK_UNQUOTED([dpkg-realpath usr/bin/a-shell], [],
+[$tmpdir/usr/bin/a-shell
+])
+AT_CHECK([dpkg-realpath usr/bin/sh], [], [/usr/bin/a-shell
+])
+
+# Absolute paths
+cd /
+AT_CHECK_UNQUOTED([dpkg-realpath "$tmpdir/aa/bb/cc"], [], [$tmpdir/aa/bb/cc
+])
+AT_CHECK_UNQUOTED([dpkg-realpath "$tmpdir/zz/yy/xx"], [], [$tmpdir/zz/yy/xx
+])
+AT_CHECK_UNQUOTED([dpkg-realpath "$tmpdir/usr/bin"], [], [$tmpdir/usr/bin
+])
+AT_CHECK_UNQUOTED([dpkg-realpath "$tmpdir/aa/bb/cc/file"], [],
+[$tmpdir/aa/bb/cc/file
+])
+AT_CHECK_UNQUOTED([dpkg-realpath "$tmpdir/zz/yy/xx/symlink-rel"], [],
+[$tmpdir/zz/yy/xx/aa/bb/cc/file
+])
+AT_CHECK([dpkg-realpath "$tmpdir/zz/yy/xx/symlink-abs"], [], [/aa/bb/cc/file
+])
+AT_CHECK_UNQUOTED([dpkg-realpath "$tmpdir/usr/bin/a-shell"], [],
+[$tmpdir/usr/bin/a-shell
+])
+AT_CHECK([dpkg-realpath "$tmpdir/usr/bin/sh"], [], [/usr/bin/a-shell
+])
+
+# Chrooted paths
+DPKG_ROOT="$tmpdir"
+AT_CHECK([dpkg-realpath /aa/bb/cc], [], [/aa/bb/cc
+])
+AT_CHECK([dpkg-realpath /zz/yy/xx], [], [/zz/yy/xx
+])
+AT_CHECK([dpkg-realpath /usr/bin], [], [/usr/bin
+])
+AT_CHECK([dpkg-realpath /aa/bb/cc/file], [], [/aa/bb/cc/file
+])
+AT_CHECK([dpkg-realpath /zz/yy/xx/symlink-rel], [], [/zz/yy/xx/aa/bb/cc/file
+])
+AT_CHECK([dpkg-realpath /zz/yy/xx/symlink-abs], [], [/aa/bb/cc/file
+])
+AT_CHECK([dpkg-realpath /usr/bin/a-shell], [], [/usr/bin/a-shell
+])
+AT_CHECK([dpkg-realpath /usr/bin/sh], [], [/usr/bin/a-shell
+])
+
+AT_CLEANUP