Home | History | Annotate | Download | only in security_SeccompSyscallFilters
      1 # Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 from autotest_lib.client.bin import test
      6 from autotest_lib.client.bin import utils
      7 from autotest_lib.client.common_lib import error
      8 
      9 import os
     10 
     11 """A test verifying that seccomp calls change permissions correctly.
     12 
     13 Compiles tests written in C and then runs them.  Fails if C tests fail.
     14 """
     15 
     16 class security_SeccompSyscallFilters(test.test):
     17     version = 1
     18     executable = 'seccomp_bpf_tests'
     19 
     20     def setup(self):
     21         """Cleans and makes seccomp_bpf_tests.c.
     22 
     23         Prepares environment for tests by removing directory we will extract
     24         to (if it exists), extracting tarball of tests, and making them.
     25         """
     26         os.chdir(self.srcdir)
     27         utils.make()
     28 
     29     def run_once(self):
     30         """Main function.
     31 
     32         Runs the compiled tests, logs output.  Fails if the call to run
     33         tests fails (meaning that a test failed). Runs both as root
     34         and non-root.
     35         """
     36         binpath = os.path.join(self.srcdir, self.executable)
     37         utils.system_output(binpath, retain_output = True)
     38         utils.system_output("su chronos -c %s" % binpath, retain_output = True)
     39