Skip to content

Commit 78851bc

Browse files
committed
fix(create-snapshot): workaround tests directory
The test infra assumes CWD is 'ROOT/tests'. create_snapshot_artifact runs from the root '.', so some functions can fail. Workaround by changing to tests while doing the imports. Original error: ``` [12] Command: cd ../src/firecracker && cargo pkgid | cut -d# -f2 | cut -d: -f2 [12] stdout: [12] stderr: /bin/sh: 1: cd: can't cd to ../src/firecracker Returned error code: 2 stderr: /bin/sh: 1: cd: can't cd to ../src/firecracker ``` Signed-off-by: Pablo Barbáchano <pablob@amazon.com>
1 parent cdf4fef commit 78851bc

File tree

1 file changed

+4
-0
lines changed
  • tools/create_snapshot_artifact

1 file changed

+4
-0
lines changed

tools/create_snapshot_artifact/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
sys.path.append(os.path.join(os.getcwd(), "tests")) # noqa: E402
1616

1717
# pylint: disable=wrong-import-position
18+
# The test infra assumes it is running from the `tests` directory.
19+
os.chdir("tests")
1820
from conftest import _test_images_s3_bucket, _gcc_compile, init_microvm
1921
from framework.artifacts import (
2022
ArtifactCollection,
@@ -32,6 +34,8 @@
3234
from framework.utils_cpuid import CpuVendor, get_cpu_vendor
3335
from integration_tests.functional.test_cmd_line_start import _configure_vm_from_json
3436
import host_tools.network as net_tools # pylint: disable=import-error
37+
# restore directory
38+
os.chdir("..")
3539

3640
DEST_KERNEL_NAME = "vmlinux.bin"
3741
ROOTFS_KEY = "ubuntu-18.04"

0 commit comments

Comments
 (0)