Skip to content

Commit 67ae67f

Browse files
committed
feat: add jailer_time binary for jailer perf tests
This binary just outputs the start and end time of the jailer startup. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent b21692d commit 67ae67f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,17 @@ def msr_reader_bin(test_fc_session_root_path):
274274
yield msr_reader_bin_path
275275

276276

277+
@pytest.fixture(scope="session")
278+
def jailer_time_bin(test_fc_session_root_path):
279+
"""Build a binary that fakes fc"""
280+
jailer_time_bin_path = os.path.join(test_fc_session_root_path, "jailer_time")
281+
build_tools.gcc_compile(
282+
"host_tools/jailer_time.c",
283+
jailer_time_bin_path,
284+
)
285+
yield jailer_time_bin_path
286+
287+
277288
@pytest.fixture
278289
def bin_seccomp_paths():
279290
"""Build jailers and jailed binaries to test seccomp.

tests/host_tools/jailer_time.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
// This is used by `performance/test_jailer.py`
5+
6+
#include <stdio.h>
7+
#include <time.h>
8+
9+
int main(int argc, char** argv) {
10+
// print current time in us
11+
struct timespec now = {0};
12+
clock_gettime(CLOCK_MONOTONIC, &now);
13+
unsigned long long current_ns = (unsigned long long)now.tv_sec * 1000000000 + (unsigned long long)now.tv_nsec;
14+
unsigned long long current_us = current_ns / 1000;
15+
printf("%llu\n", current_us);
16+
17+
// print the --start-time-us value
18+
printf("%s", argv[4]);
19+
}

0 commit comments

Comments
 (0)