Skip to content

Commit 5fcaa7a

Browse files
committed
Add IPC test for devdax memory provider
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 03cfaa1 commit 5fcaa7a

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

test/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,36 @@ if(LINUX)
356356
add_umf_ipc_test(TEST ipc_os_prov_anon_fd)
357357
add_umf_ipc_test(TEST ipc_os_prov_shm)
358358
endif()
359+
if(UMF_TESTS_DEVDAX_PATH AND UMF_TESTS_DEVDAX_SIZE)
360+
build_umf_test(
361+
NAME
362+
ipc_devdax_prov_consumer
363+
SRCS
364+
ipc_devdax_prov_consumer.c
365+
common/ipc_common.c
366+
common/ipc_os_prov_common.c)
367+
build_umf_test(
368+
NAME
369+
ipc_devdax_prov_producer
370+
SRCS
371+
ipc_devdax_prov_producer.c
372+
common/ipc_common.c
373+
common/ipc_os_prov_common.c)
374+
target_compile_definitions(
375+
umf_test-ipc_devdax_prov_consumer
376+
PRIVATE UMF_TESTS_DEVDAX_PATH="${UMF_TESTS_DEVDAX_PATH}"
377+
UMF_TESTS_DEVDAX_SIZE=${UMF_TESTS_DEVDAX_SIZE})
378+
target_compile_definitions(
379+
umf_test-ipc_devdax_prov_producer
380+
PRIVATE UMF_TESTS_DEVDAX_PATH="${UMF_TESTS_DEVDAX_PATH}"
381+
UMF_TESTS_DEVDAX_SIZE=${UMF_TESTS_DEVDAX_SIZE})
382+
add_umf_ipc_test(TEST ipc_devdax_prov)
383+
else()
384+
message(
385+
STATUS
386+
"UMF_TESTS_DEVDAX_PATH or UMF_TESTS_DEVDAX_SIZE is not set - skipping the IPC devdax memory provider test"
387+
)
388+
endif()
359389
if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
360390
build_umf_test(
361391
NAME

test/ipc_devdax_prov.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
# port should be a number from the range <1024, 65535>
13+
PORT=$(( 1024 + ( $$ % ( 65535 - 1024 ))))
14+
15+
UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes"
16+
17+
echo "Starting ipc_devdax_prov CONSUMER on port $PORT ..."
18+
UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_devdax_prov_consumer $PORT &
19+
20+
echo "Waiting 1 sec ..."
21+
sleep 1
22+
23+
echo "Starting ipc_devdax_prov PRODUCER on port $PORT ..."
24+
UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_devdax_prov_producer $PORT

test/ipc_devdax_prov_consumer.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
umf_devdax_memory_provider_params_t devdax_params =
25+
umfDevDaxMemoryProviderParamsDefault(UMF_TESTS_DEVDAX_PATH,
26+
UMF_TESTS_DEVDAX_SIZE);
27+
28+
return run_consumer(port, umfDevDaxMemoryProviderOps(), &devdax_params,
29+
memcopy, NULL);
30+
}

test/ipc_devdax_prov_producer.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
umf_devdax_memory_provider_params_t devdax_params =
25+
umfDevDaxMemoryProviderParamsDefault(UMF_TESTS_DEVDAX_PATH,
26+
UMF_TESTS_DEVDAX_SIZE);
27+
28+
return run_producer(port, umfDevDaxMemoryProviderOps(), &devdax_params,
29+
memcopy, NULL);
30+
}

0 commit comments

Comments
 (0)