summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2015-07-15 22:32:12 +0200
committerPaul Moore <pmoore@redhat.com>2015-07-16 22:06:35 -0400
commitbfac175ac1222ca59045eeecd8d27df9dd7bab4d (patch)
treefc2e7872e53799a40c3a0b77fcc7a4493f58b827
parentb104193d48d479b7e342c292ddcae0133575f68a (diff)
downloadlibseccomp-bfac175ac1222ca59045eeecd8d27df9dd7bab4d.tar.gz
tests: fix sequence number generation
Because of incorrect number sequence generation by seq(1) on at least 32 bit ARM systems using coreutils v8.23/v8.24 we provide a minimal seq(1) implementation that fits our needs. This fixes the bug mentioned in the following mailing thread: https://groups.google.com/forum/#!topic/libseccomp/VtrClkXxLGA Signed-off-by: Mathias Krause <minipli@googlemail.com> [PM: subject line, build locations, and vertical whitespace tweaks] Signed-off-by: Paul Moore <pmoore@redhat.com>
-rw-r--r--tests/.gitignore2
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/miniseq.c57
-rwxr-xr-xtests/regression34
4 files changed, 85 insertions, 9 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index 43ba0c1..d47ea65 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,6 +1,7 @@
*.bpf
*.bpfd
*.pfc
+miniseq
util.pyc
00-test.c
00-test
@@ -32,3 +33,4 @@ util.pyc
26-sim-arch_all_be_basic
27-sim-bpf_blk_state
28-sim-arch_x86
+
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 25cef75..b2863bb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -26,6 +26,7 @@ util_la_LDFLAGS = -module
TESTS = regression
check_PROGRAMS = \
+ miniseq \
01-sim-allow \
02-sim-basic \
03-sim-basic_chains \
diff --git a/tests/miniseq.c b/tests/miniseq.c
new file mode 100644
index 0000000..7addc70
--- /dev/null
+++ b/tests/miniseq.c
@@ -0,0 +1,57 @@
+/**
+ * Seccomp Library test support program
+ *
+ * Copyright (c) 2015 Mathias Krause <minipli@googlemail.com>
+ */
+
+/*
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <errno.h>
+
+static int get_number(char *str, uint64_t *res)
+{
+ char *end = str;
+
+ errno = 0;
+ *res = strtoull(str, &end, 0);
+ if (errno || *end != '\0') {
+ fprintf(stderr, "error: failed to convert '%s'\n", str);
+ return -1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ uint64_t first, last, cur;
+
+ if (argc != 3) {
+ fprintf(stderr, "usage: %s FIRST LAST\n", argv[0]);
+ return 1;
+ }
+
+ if (get_number(argv[1], &first) || get_number(argv[2], &last))
+ return 1;
+
+ for (cur = first; cur <= last; cur++)
+ printf("%" PRIu64 "\n", cur);
+
+ return 0;
+}
diff --git a/tests/regression b/tests/regression
index 428bdf2..acb125d 100755
--- a/tests/regression
+++ b/tests/regression
@@ -164,6 +164,23 @@ function get_range() {
}
#
+# Get the number sequence for a given range with increments of 1, i.e.
+# implement a specialized seq(1).
+#
+# We use our own implementation based on miniseq in favour to the standard seq
+# tool as, at least, seq of coreutils v8.23 and v8.24 has problems on 32 bit
+# ARM for large numbers (see the mailing thread at
+# https://groups.google.com/forum/#!topic/libseccomp/VtrClkXxLGA).
+#
+# Arguments:
+# 1 starting value
+# 2 last value
+#
+function get_seq() {
+ ${basedir}/miniseq "$1" "$2"
+}
+
+#
# Run the specified test command (with valgrind if requested)
#
# Arguments:
@@ -245,7 +262,7 @@ function run_test_bpf_sim_fuzz() {
local testname=${line[0]}
local stress_count=${line[1]}
- for i in $(seq 1 $stress_count); do
+ for i in $(get_seq 1 $stress_count); do
local sys=$(generate_random_data)
local -a arg=($(generate_random_data) $(generate_random_data) \
$(generate_random_data) $(generate_random_data) \
@@ -462,13 +479,13 @@ function run_test_bpf_sim() {
# and arg ranges and generate/run every combination of requested
# tests; if no ranges were specifed, then the single test is
# run
- for sys in $(seq -f "%1.0f" $low_syscall $high_syscall); do
- for arg0 in $(seq -f "%1.0f" ${low_arg[0]} ${high_arg[0]}); do
- for arg1 in $(seq -f "%1.0f" ${low_arg[1]} ${high_arg[1]}); do
- for arg2 in $(seq -f "%1.0f" ${low_arg[2]} ${high_arg[2]}); do
- for arg3 in $(seq -f "%1.0f" ${low_arg[3]} ${high_arg[3]}); do
- for arg4 in $(seq -f "%1.0f" ${low_arg[4]} ${high_arg[4]}); do
- for arg5 in $(seq -f "%1.0f" ${low_arg[5]} ${high_arg[5]}); do
+ for sys in $(get_seq $low_syscall $high_syscall); do
+ for arg0 in $(get_seq ${low_arg[0]} ${high_arg[0]}); do
+ for arg1 in $(get_seq ${low_arg[1]} ${high_arg[1]}); do
+ for arg2 in $(get_seq ${low_arg[2]} ${high_arg[2]}); do
+ for arg3 in $(get_seq ${low_arg[3]} ${high_arg[3]}); do
+ for arg4 in $(get_seq ${low_arg[4]} ${high_arg[4]}); do
+ for arg5 in $(get_seq ${low_arg[5]} ${high_arg[5]}); do
local -a arg=($arg0 $arg1 $arg2 $arg3 $arg4 $arg5)
# Get the generated sub-test num string
@@ -827,7 +844,6 @@ function run_tests() {
verify_deps head
verify_deps sed
verify_deps awk
-verify_deps seq
verify_deps tr
# global variables