Skip to content

Commit 2208672

Browse files
pb8ozulinx86
authored andcommitted
test: add a helper shell script to run tests
The script will set up a TMPDIR and will copy the test artifacts to /srv so they can be hardlinked to save space and IO. Signed-off-by: Pablo Barbáchano <pablob@amazon.com>
1 parent 4504f66 commit 2208672

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

tests/framework/defs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545

4646
SUPPORTED_HOST_KERNELS = ["4.14", "5.10", "6.1"]
4747

48+
IMG_DIR = Path(DEFAULT_TEST_SESSION_ROOT_PATH) / "img"
4849

49-
ARTIFACT_DIR = (
50-
Path(__file__).joinpath("../../../build/img").resolve() / platform.machine()
51-
)
50+
# fall-back to the local directory
51+
if not IMG_DIR.exists():
52+
IMG_DIR = Path(__file__).joinpath("../../../build/img").resolve()
53+
54+
ARTIFACT_DIR = IMG_DIR / platform.machine()

tools/devtool

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,14 +624,14 @@ cmd_test() {
624624
--ulimit core=0 \
625625
--ulimit nofile=4096:4096 \
626626
--ulimit memlock=-1:-1 \
627-
--workdir "$CTR_FC_ROOT_DIR/tests" \
627+
--workdir "$CTR_FC_ROOT_DIR" \
628628
--cpuset-cpus="$cpuset_cpus" \
629629
--cpuset-mems="$cpuset_mems" \
630630
--env-file env.list \
631631
-v /boot:/boot \
632632
${ramdisk_args} \
633633
-- \
634-
pytest "$@"
634+
./tools/test.sh "$@"
635635

636636
ret=$?
637637

tools/test.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# fail if we encounter an error, uninitialized variable or a pipe breaks
7+
set -eu -o pipefail
8+
9+
TOOLS_DIR=$(dirname $0)
10+
source "$TOOLS_DIR/functions"
11+
12+
# Set our TMPDIR inside /srv, so all files created in the session end up in one
13+
# place
14+
say "Create TMPDIR in /srv"
15+
export TMPDIR=/srv/tmp
16+
mkdir -pv $TMPDIR
17+
18+
say "Copy CI artifacts to /srv, so hardlinks work"
19+
cp -ruvf build/img /srv
20+
21+
cd tests
22+
pytest "$@"
23+
exit $?

0 commit comments

Comments
 (0)