Home | History | Annotate | Download | only in seccomp-tests
      1 # Seccomp-BPF Kernel Self-Test Suite
      2 
      3 This repository contains a mirror of the upstream Linux kernel test suite for the Seccomp-BPF
      4 system call filter. The test suite runs as part of CTS, but it is maintained in a separate
      5 repository because the code is GPL.
      6 
      7 ## Syncing to Upstream
      8 
      9 Rather than hold the entire Linux history in this repository, only the subdirectory for the Seccomp
     10 selftests are preserved here. In order to sync this repository to the upstream Linux, follow these
     11 instructions.
     12 
     13 The pristine copy of the upstream source is kept on a branch called upstream-master. This branch is
     14 then merged into an Android development branch.
     15 
     16 ### First-Time Setup
     17 
     18 These instructions only need to be followed for the first time you are updating the repository from
     19 a checkout.
     20 
     21 1. Configure a remote to use as the source repository (limited to only syncing the master branch):
     22     ```
     23     git remote add upstream-linux git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git -t master --no-tags
     24     ```
     25 
     26 ### Updating the Source
     27 
     28 Perform these steps every time you need to update the test suite from upstream.
     29 
     30 1. Update the remote to fetch the latest sources:
     31     ```
     32     git remote update upstream-linux
     33     ```
     34 
     35 2. Create a new local branch from the updated source, replacing YYYYMMDD with today's date:
     36     ```
     37     git checkout -b update-YYYYMMDD upstream-linux/master
     38     ```
     39 
     40 3. Filter the branch to just the subtree containing the Seccomp test suite:
     41     ```
     42     git filter-branch --subdirectory-filter tools/testing/selftests/seccomp
     43     ```
     44 
     45 4. Check out the upstream-master branch, which contains the pristine, filter-branch'd copy of the
     46 source code. Pushing non-merge commits with a "forged" author/committer can only be done against
     47 the upstream-master branch.
     48     ```
     49     git checkout -b upstream-master aosp/upstream-master
     50     ````
     51 
     52 5. Update this upstream-master branch to the newly filtered branch of upstream-linux.
     53     ```
     54     git merge --ff-only update-YYYYMMDD
     55     ```
     56 
     57 6. Upload the changes on upstream-master for review and submit them.
     58 
     59 7. Merge the changes from upstream-master into the Android development branch (typically master).
     60 Resolve any conflicts with the local modifications present in the repository.
     61     ```
     62     repo start sync-upstream .
     63     git subtree merge -P linux/ upstream-master
     64     ```
     65 
     66 Now build and test the changes by running CTS:
     67 
     68     $ mmma cts/tests/tests/os
     69     $ cts-tradefed run singleCommand cts -m CtsOsTestCases -t android.os.cts.SeccompTest
     70 
     71 The tests are expected to pass on arm, arm64, x86, and x86\_64. If they pass, then repo
     72 upload/submit the CL branch. Afterwards, you can remove the update-YYYYMMDD branch.
     73 
     74 ### Linux Space-Saving
     75 
     76 If you already have a Linux kernel checkout, you can skip adding Linux as a remote and instead
     77 perform steps 1-3 of "Updating the Source" in the kernel checkout. Then simply fetch the filtered
     78 branch into the seccomp-tests repository and subtree merge it (as FETCH\_HEAD). This will avoid
     79 copying the entire kernel history into your local checkout.
     80