summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/zstd/tests/cli-tests/common
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/zstd/tests/cli-tests/common')
-rw-r--r--3rdparty/zstd/tests/cli-tests/common/format.sh19
-rw-r--r--3rdparty/zstd/tests/cli-tests/common/mtime.sh13
-rw-r--r--3rdparty/zstd/tests/cli-tests/common/permissions.sh18
-rw-r--r--3rdparty/zstd/tests/cli-tests/common/platform.sh37
4 files changed, 87 insertions, 0 deletions
diff --git a/3rdparty/zstd/tests/cli-tests/common/format.sh b/3rdparty/zstd/tests/cli-tests/common/format.sh
new file mode 100644
index 00000000000..e574e973075
--- /dev/null
+++ b/3rdparty/zstd/tests/cli-tests/common/format.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+. "$COMMON/platform.sh"
+
+zstd_supports_format()
+{
+ zstd -h | grep > $INTOVOID -- "--format=$1"
+}
+
+format_extension()
+{
+ if [ "$1" = "zstd" ]; then
+ printf "zst"
+ elif [ "$1" = "gzip" ]; then
+ printf "gz"
+ else
+ printf "$1"
+ fi
+}
diff --git a/3rdparty/zstd/tests/cli-tests/common/mtime.sh b/3rdparty/zstd/tests/cli-tests/common/mtime.sh
new file mode 100644
index 00000000000..344074d398c
--- /dev/null
+++ b/3rdparty/zstd/tests/cli-tests/common/mtime.sh
@@ -0,0 +1,13 @@
+. "$COMMON/platform.sh"
+
+MTIME="stat -c %Y"
+case "$UNAME" in
+ Darwin | FreeBSD | OpenBSD | NetBSD) MTIME="stat -f %m" ;;
+esac
+
+assertSameMTime() {
+ MT1=$($MTIME "$1")
+ MT2=$($MTIME "$2")
+ echo MTIME $MT1 $MT2
+ [ "$MT1" = "$MT2" ] || die "mtime on $1 doesn't match mtime on $2 ($MT1 != $MT2)"
+}
diff --git a/3rdparty/zstd/tests/cli-tests/common/permissions.sh b/3rdparty/zstd/tests/cli-tests/common/permissions.sh
new file mode 100644
index 00000000000..6bce1f0b387
--- /dev/null
+++ b/3rdparty/zstd/tests/cli-tests/common/permissions.sh
@@ -0,0 +1,18 @@
+. "$COMMON/platform.sh"
+
+GET_PERMS="stat -c %a"
+case "$UNAME" in
+ Darwin | FreeBSD | OpenBSD | NetBSD) GET_PERMS="stat -f %Lp" ;;
+esac
+
+assertFilePermissions() {
+ STAT1=$($GET_PERMS "$1")
+ STAT2=$2
+ [ "$STAT1" = "$STAT2" ] || die "permissions on $1 don't match expected ($STAT1 != $STAT2)"
+}
+
+assertSamePermissions() {
+ STAT1=$($GET_PERMS "$1")
+ STAT2=$($GET_PERMS "$2")
+ [ "$STAT1" = "$STAT2" ] || die "permissions on $1 don't match those on $2 ($STAT1 != $STAT2)"
+}
diff --git a/3rdparty/zstd/tests/cli-tests/common/platform.sh b/3rdparty/zstd/tests/cli-tests/common/platform.sh
new file mode 100644
index 00000000000..6eb45eab99e
--- /dev/null
+++ b/3rdparty/zstd/tests/cli-tests/common/platform.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+UNAME=$(uname)
+
+isWindows=false
+INTOVOID="/dev/null"
+case "$UNAME" in
+ GNU) DEVDEVICE="/dev/random" ;;
+ *) DEVDEVICE="/dev/zero" ;;
+esac
+case "$OS" in
+ Windows*)
+ isWindows=true
+ INTOVOID="NUL"
+ DEVDEVICE="NUL"
+ ;;
+esac
+
+case "$UNAME" in
+ Darwin) MD5SUM="md5 -r" ;;
+ FreeBSD) MD5SUM="gmd5sum" ;;
+ NetBSD) MD5SUM="md5 -n" ;;
+ OpenBSD) MD5SUM="md5" ;;
+ *) MD5SUM="md5sum" ;;
+esac
+
+DIFF="diff"
+case "$UNAME" in
+ SunOS) DIFF="gdiff" ;;
+esac
+
+if echo hello | zstd -v -T2 2>&1 > $INTOVOID | grep -q 'multi-threading is disabled'
+then
+ hasMT=""
+else
+ hasMT="true"
+fi