shithub: scc

Download patch

ref: 09f5da73611db3395b97ab9e1746a0eb4e9736af
parent: cb32df0efbd91bd9f1c1b3840086133b2e7dd6b2
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Feb 19 11:23:20 EST 2018

[tests/ar] Add tests for -d

--- /dev/null
+++ b/tests/ar/execute/10-test-d.sh
@@ -1,0 +1,94 @@
+#!/bin/sh
+
+exec >> test.log 2>&1
+
+set -e
+
+trap "rm -f file.a" 0 2 3
+
+############################################################################
+#delete one member
+
+cp master.a file.a
+
+ar -dv file.a file2
+
+if ar -tv file.a file2
+then
+	echo file-2 was not deleted >&2
+	exit 1
+fi
+
+
+############################################################################
+#delete two members, 1st and 2nd
+
+cp master.a file.a
+
+ar -dv file.a file1 file2
+
+if ar -tv file.a file1 file2
+then
+	echo file-1 or file-2 were not deleted >&2
+	exit 1
+fi
+
+
+############################################################################
+#delete two members, 2nd and 3rd
+
+cp master.a file.a
+ar -dv  file.a file2 file3
+
+if ar -tv file.a file2 file3
+then
+	echo file-2 file-3 were not deleted >&2
+	exit 1
+fi
+
+############################################################################
+#remove all the members
+
+cp master.a file.a
+ar -dv file.a file1 file2 file3
+
+if ar -tv file.a file2 file3
+then
+	echo file-1 file2 file were not deleted >&2
+	exit 1
+fi
+
+if test `ar -t file.a | wc -l` -ne 0
+then
+	echo file.a is not empty after deleting all the members >&2
+	exit 1
+fi
+
+############################################################################
+#special cases
+
+#no members
+cp master.a file.a
+
+last=`stat -c %Y file.a`
+
+if ! ar -dv file.a
+then
+	echo ar returned with error when no members
+	exit 1
+fi
+
+if test `stat -c %Y file.a` -ne $last
+then
+	echo empty ar -d modified the archive >&2
+	exit 1
+fi
+
+#delete not existing member
+cp master.a file.a
+
+if ar -dv file.a badfile
+then
+	echo ar returned ok deleting a not existing member >&2
+	exit 1
+fi