Skip to content

Commit 52ea0c1

Browse files
committed
Add IPC test for devdax memory provider
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 251ee0c commit 52ea0c1

File tree

5 files changed

+140
-0
lines changed

5 files changed

+140
-0
lines changed

test/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,22 @@ if(LINUX)
344344
common/ipc_os_prov_common.c)
345345
add_umf_ipc_test(TEST ipc_os_prov_anon_fd)
346346
add_umf_ipc_test(TEST ipc_os_prov_shm)
347+
348+
build_umf_test(
349+
NAME
350+
ipc_devdax_prov_consumer
351+
SRCS
352+
ipc_devdax_prov_consumer.c
353+
common/ipc_common.c
354+
common/ipc_os_prov_common.c)
355+
build_umf_test(
356+
NAME
357+
ipc_devdax_prov_producer
358+
SRCS
359+
ipc_devdax_prov_producer.c
360+
common/ipc_common.c
361+
common/ipc_os_prov_common.c)
362+
add_umf_ipc_test(TEST ipc_devdax_prov)
347363
endif()
348364
if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
349365
build_umf_test(

test/ipc_devdax_prov.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Copyright (C) 2024 Intel Corporation
3+
#
4+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
5+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
#
7+
8+
#!/bin/bash
9+
10+
set -e
11+
12+
if [ "$UMF_TESTS_DEVDAX_PATH" == "" ]; then
13+
echo "Test skipped, UMF_TESTS_DEVDAX_PATH is not set"
14+
exit 0
15+
fi
16+
17+
if [ "$UMF_TESTS_DEVDAX_SIZE" == "" ]; then
18+
echo "Test skipped, UMF_TESTS_DEVDAX_SIZE is not set"
19+
exit 0
20+
fi
21+
22+
# port should be a number from the range <1024, 65535>
23+
PORT=$(( 1024 + ( $$ % ( 65535 - 1024 ))))
24+
25+
UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes"
26+
27+
echo "Starting ipc_devdax_prov CONSUMER on port $PORT ..."
28+
UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_devdax_prov_consumer $PORT &
29+
30+
echo "Waiting 1 sec ..."
31+
sleep 1
32+
33+
echo "Starting ipc_devdax_prov PRODUCER on port $PORT ..."
34+
UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_devdax_prov_producer $PORT

test/ipc_devdax_prov_consumer.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2024 Intel Corporation
3+
*
4+
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
5+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
*/
7+
8+
#include <stdio.h>
9+
#include <stdlib.h>
10+
11+
#include <umf/providers/provider_devdax_memory.h>
12+
13+
#include "ipc_common.h"
14+
#include "ipc_os_prov_common.h"
15+
16+
int main(int argc, char *argv[]) {
17+
if (argc < 2) {
18+
fprintf(stderr, "usage: %s <port>\n", argv[0]);
19+
return -1;
20+
}
21+
22+
int port = atoi(argv[1]);
23+
24+
char *path = getenv("UMF_TESTS_DEVDAX_PATH");
25+
if (path == NULL || path[0] == 0) {
26+
fprintf(stderr, "Test skipped, UMF_TESTS_DEVDAX_PATH is not set\n");
27+
return 0;
28+
}
29+
30+
char *size = getenv("UMF_TESTS_DEVDAX_SIZE");
31+
if (size == NULL || size[0] == 0) {
32+
fprintf(stderr, "Test skipped, UMF_TESTS_DEVDAX_SIZE is not set\n");
33+
return 0;
34+
}
35+
36+
umf_devdax_memory_provider_params_t devdax_params =
37+
umfDevDaxMemoryProviderParamsDefault(
38+
getenv("UMF_TESTS_DEVDAX_PATH"),
39+
atol(getenv("UMF_TESTS_DEVDAX_SIZE")));
40+
41+
return run_consumer(port, umfDevDaxMemoryProviderOps(), &devdax_params,
42+
memcopy, NULL);
43+
}

test/ipc_devdax_prov_producer.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2024 Intel Corporation
3+
*
4+
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
5+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
*/
7+
8+
#include <stdio.h>
9+
#include <stdlib.h>
10+
11+
#include <umf/providers/provider_devdax_memory.h>
12+
13+
#include "ipc_common.h"
14+
#include "ipc_os_prov_common.h"
15+
16+
int main(int argc, char *argv[]) {
17+
if (argc < 2) {
18+
fprintf(stderr, "usage: %s <port>\n", argv[0]);
19+
return -1;
20+
}
21+
22+
int port = atoi(argv[1]);
23+
24+
char *path = getenv("UMF_TESTS_DEVDAX_PATH");
25+
if (path == NULL || path[0] == 0) {
26+
fprintf(stderr, "Test skipped, UMF_TESTS_DEVDAX_PATH is not set\n");
27+
return 0;
28+
}
29+
30+
char *size = getenv("UMF_TESTS_DEVDAX_SIZE");
31+
if (size == NULL || size[0] == 0) {
32+
fprintf(stderr, "Test skipped, UMF_TESTS_DEVDAX_SIZE is not set\n");
33+
return 0;
34+
}
35+
36+
umf_devdax_memory_provider_params_t devdax_params =
37+
umfDevDaxMemoryProviderParamsDefault(
38+
getenv("UMF_TESTS_DEVDAX_PATH"),
39+
atol(getenv("UMF_TESTS_DEVDAX_SIZE")));
40+
41+
return run_producer(port, umfDevDaxMemoryProviderOps(), &devdax_params,
42+
memcopy, NULL);
43+
}

test/test_valgrind.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ for test in $(ls -1 umf_test-*); do
8888
echo "- SKIPPED"
8989
continue; # skip testing helper binaries used by the ipc_os_prov_* tests
9090
;;
91+
umf_test-ipc_devdax_prov_*)
92+
echo "- SKIPPED"
93+
continue; # skip testing helper binaries used by the ipc_devdax_prov_* tests
94+
;;
9195
umf_test-memspace_host_all)
9296
FILTER='--gtest_filter="-*allocsSpreadAcrossAllNumaNodes"'
9397
;;

0 commit comments

Comments
 (0)