Skip to content

Commit 4603b7e

Browse files
committed
Add IPC test for file memory provider
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent a55e42e commit 4603b7e

5 files changed

+117
-0
lines changed

test/CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,24 @@ if(LINUX)
370370
common/ipc_common.c
371371
common/ipc_os_prov_common.c)
372372
add_umf_ipc_test(TEST ipc_devdax_prov)
373+
374+
build_umf_test(
375+
NAME
376+
ipc_file_prov_consumer
377+
SRCS
378+
ipc_file_prov_consumer.c
379+
common/ipc_common.c
380+
common/ipc_os_prov_common.c)
381+
build_umf_test(
382+
NAME
383+
ipc_file_prov_producer
384+
SRCS
385+
ipc_file_prov_producer.c
386+
common/ipc_common.c
387+
common/ipc_os_prov_common.c)
388+
add_umf_ipc_test(TEST ipc_file_prov)
373389
endif()
390+
374391
if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
375392
build_umf_test(
376393
NAME

test/ipc_file_prov.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
FILE_NAME="/tmp/umf_file_provider_$$"
13+
14+
# port should be a number from the range <1024, 65535>
15+
PORT=$(( 1024 + ( $$ % ( 65535 - 1024 ))))
16+
17+
UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes"
18+
19+
# make sure the temp file does not exist
20+
rm -f ${FILE_NAME}
21+
22+
echo "Starting ipc_file_prov CONSUMER on port $PORT ..."
23+
UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_consumer $PORT $FILE_NAME &
24+
25+
echo "Waiting 1 sec ..."
26+
sleep 1
27+
28+
echo "Starting ipc_file_prov PRODUCER on port $PORT ..."
29+
UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_producer $PORT $FILE_NAME
30+
31+
# remove the SHM file
32+
rm -f ${FILE_NAME}

test/ipc_file_prov_consumer.c

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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_file_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 < 3) {
18+
fprintf(stderr, "usage: %s <port> <file_name>\n", argv[0]);
19+
return -1;
20+
}
21+
22+
int port = atoi(argv[1]);
23+
char *file_name = argv[2];
24+
25+
umf_file_memory_provider_params_t file_params;
26+
27+
file_params = umfFileMemoryProviderParamsDefault(file_name);
28+
file_params.visibility = UMF_MEM_MAP_SHARED;
29+
30+
return run_consumer(port, umfFileMemoryProviderOps(), &file_params, memcopy,
31+
NULL);
32+
}

test/ipc_file_prov_producer.c

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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_file_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 < 3) {
18+
fprintf(stderr, "usage: %s <port> <file_name>\n", argv[0]);
19+
return -1;
20+
}
21+
22+
int port = atoi(argv[1]);
23+
char *file_name = argv[2];
24+
25+
umf_file_memory_provider_params_t file_params;
26+
27+
file_params = umfFileMemoryProviderParamsDefault(file_name);
28+
file_params.visibility = UMF_MEM_MAP_SHARED;
29+
30+
return run_producer(port, umfFileMemoryProviderOps(), &file_params, memcopy,
31+
NULL);
32+
}

test/test_valgrind.sh

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ for test in $(ls -1 umf_test-*); do
9292
echo "- SKIPPED"
9393
continue; # skip testing helper binaries used by the ipc_devdax_prov_* tests
9494
;;
95+
umf_test-ipc_file_prov_*)
96+
echo "- SKIPPED"
97+
continue; # skip testing helper binaries used by the ipc_file_prov test
98+
;;
9599
umf_test-memspace_host_all)
96100
FILTER='--gtest_filter="-*allocsSpreadAcrossAllNumaNodes"'
97101
;;

0 commit comments

Comments
 (0)