The new test is similar to 23-sim-arch_all_le_basic

Signed-off-by: Markos Chandras <[email protected]>
---
Regression Test Summary
tests run: 6465
tests skipped: 53
tests passed: 6465
tests failed: 0
tests errored: 0
---
 tests/26-sim-arch_all_be_basic.c     | 84 ++++++++++++++++++++++++++++++++++++
 tests/26-sim-arch_all_be_basic.py    | 50 +++++++++++++++++++++
 tests/26-sim-arch_all_be_basic.tests | 25 +++++++++++
 tests/Makefile                       |  3 +-
 4 files changed, 161 insertions(+), 1 deletion(-)
 create mode 100644 tests/26-sim-arch_all_be_basic.c
 create mode 100755 tests/26-sim-arch_all_be_basic.py
 create mode 100644 tests/26-sim-arch_all_be_basic.tests

diff --git a/tests/26-sim-arch_all_be_basic.c b/tests/26-sim-arch_all_be_basic.c
new file mode 100644
index 0000000..8fccef5
--- /dev/null
+++ b/tests/26-sim-arch_all_be_basic.c
@@ -0,0 +1,84 @@
+/**
+ * Seccomp Library test program
+ *
+ * Copyright (c) 2014 Red Hat <[email protected]>
+ * Author: Markos Chandras <[email protected]>
+ */
+
+/*
+ * 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 <unistd.h>
+
+#include <seccomp.h>
+
+#include "util.h"
+
+int main(int argc, char *argv[])
+{
+       int rc;
+       struct util_options opts;
+       scmp_filter_ctx ctx = NULL;
+
+       rc = util_getopt(argc, argv, &opts);
+       if (rc < 0)
+               goto out;
+
+       ctx = seccomp_init(SCMP_ACT_KILL);
+       if (ctx == NULL)
+               goto out;
+
+       /*
+        * Remove the native arch token. We will add the arch tokens
+        * ourselves.
+        */
+       seccomp_arch_remove(ctx, seccomp_arch_native());
+
+       if (seccomp_arch_exist(ctx, SCMP_ARCH_MIPS)) {
+               rc = seccomp_arch_add(ctx, SCMP_ARCH_MIPS);
+               if (rc != 0)
+                       goto out;
+       }
+
+       rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
+                             SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO));
+       if (rc != 0)
+               goto out;
+
+       rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 1,
+                             SCMP_A0(SCMP_CMP_EQ, STDOUT_FILENO));
+       if (rc != 0)
+               goto out;
+
+       rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 1,
+                             SCMP_A0(SCMP_CMP_EQ, STDERR_FILENO));
+       if (rc != 0)
+               goto out;
+
+       rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(close), 0);
+       if (rc != 0)
+               goto out;
+
+       rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(rt_sigreturn), 0);
+       if (rc != 0)
+               goto out;
+
+       rc = util_filter_output(&opts, ctx);
+       if (rc)
+               goto out;
+
+out:
+       seccomp_release(ctx);
+       return (rc < 0 ? -rc : rc);
+}
diff --git a/tests/26-sim-arch_all_be_basic.py 
b/tests/26-sim-arch_all_be_basic.py
new file mode 100755
index 0000000..36073b1
--- /dev/null
+++ b/tests/26-sim-arch_all_be_basic.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+#
+# Seccomp Library test program
+#
+# Copyright (c) 2014 Red Hat <[email protected]>
+# Author: Markos Chandras <[email protected]>
+#
+
+#
+# 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>.
+#
+
+import argparse
+import sys
+
+import util
+
+from seccomp import *
+
+def test(args):
+    f = SyscallFilter(KILL)
+    # Remove the native arch token. We will add the arch tokens
+    # ourselves.
+    f.remove_arch(Arch.NATIVE)
+    if not f.exist_arch(Arch.MIPS):
+        f.add_arch(Arch.MIPS)
+    f.add_rule(ALLOW, "read", Arg(0, EQ, sys.stdin.fileno()))
+    f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stdout.fileno()))
+    f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stderr.fileno()))
+    f.add_rule(ALLOW, "close")
+    f.add_rule(ALLOW, "rt_sigreturn")
+    return f
+
+args = util.get_opt()
+ctx = test(args)
+util.filter_output(args, ctx)
+
+# kate: syntax python;
+# kate: indent-mode python; space-indent on; indent-width 4; mixedindent off;
diff --git a/tests/26-sim-arch_all_be_basic.tests 
b/tests/26-sim-arch_all_be_basic.tests
new file mode 100644
index 0000000..7cba6a8
--- /dev/null
+++ b/tests/26-sim-arch_all_be_basic.tests
@@ -0,0 +1,25 @@
+#
+# libseccomp regression test automation data
+#
+#
+# Copyright (c) 2014 Red Hat <[email protected]>
+# Author: Markos Chandras <[email protected]>
+#
+# Similar to 23-sim-arch_all_basic but for Big-Endian architectures
+#
+
+test type: bpf-sim
+
+# Testname             Arch    Syscall         Arg0            Arg1            
Arg2    Arg3    Arg4    Arg5    Result
+26-sim-arch_all_be_basic       +all_be read            0               
0x856B008       10      N       N       N       ALLOW
+26-sim-arch_all_be_basic       +all_be read            1-10            
0x856B008       10      N       N       N       KILL
+26-sim-arch_all_be_basic       +all_be write           1-2             
0x856B008       10      N       N       N       ALLOW
+26-sim-arch_all_be_basic       +all_be write           3-10            
0x856B008       10      N       N       N       KILL
+26-sim-arch_all_be_basic       +all_be close           N               N       
        N       N       N       N       ALLOW
+26-sim-arch_all_be_basic       +all_be rt_sigreturn    N               N       
        N       N       N       N       ALLOW
+26-sim-arch_all_be_basic       +all_be open            0x856B008       4       
        N       N       N       N       KILL
+
+test type: bpf-valgrind
+
+# Testname
+26-sim-arch_all_be_basic
diff --git a/tests/Makefile b/tests/Makefile
index 70a7d3d..16ce726 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -62,7 +62,8 @@ TESTS = 01-sim-allow \
        22-sim-basic_chains_array \
        23-sim-arch_all_le_basic \
        24-live-arg_allow \
-       25-sim-multilevel_chains_adv
+       25-sim-multilevel_chains_adv \
+       26-sim-arch_all_be_basic
 
 DEPS_OBJS = $(OBJS:%.o=%.d)
 DEPS_TESTS = $(TESTS:%=%.d)
-- 
1.9.2


------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
libseccomp-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libseccomp-discuss

Reply via email to