diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/pmdk/utils/docker/test_package | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pmdk/utils/docker/test_package')
-rw-r--r-- | src/pmdk/utils/docker/test_package/.gitignore | 1 | ||||
-rw-r--r-- | src/pmdk/utils/docker/test_package/Makefile | 21 | ||||
-rw-r--r-- | src/pmdk/utils/docker/test_package/README | 6 | ||||
-rw-r--r-- | src/pmdk/utils/docker/test_package/test_package.c | 41 |
4 files changed, 69 insertions, 0 deletions
diff --git a/src/pmdk/utils/docker/test_package/.gitignore b/src/pmdk/utils/docker/test_package/.gitignore new file mode 100644 index 000000000..7e564dc4e --- /dev/null +++ b/src/pmdk/utils/docker/test_package/.gitignore @@ -0,0 +1 @@ +test_package diff --git a/src/pmdk/utils/docker/test_package/Makefile b/src/pmdk/utils/docker/test_package/Makefile new file mode 100644 index 000000000..f5970aac3 --- /dev/null +++ b/src/pmdk/utils/docker/test_package/Makefile @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2018, Intel Corporation + +check_package = $(shell pkg-config $(1) && echo y || echo n) + +HAS_LIBPMEMOBJ := $(call check_package, libpmemobj --atleast-version $(LIBPMEMOBJ_MIN_VERSION) --print-errors) + +LIBS += $(shell pkg-config --libs libpmemobj) +CFLAGS += $(shell pkg-config --cflags libpmemobj) + +ifeq ($(HAS_LIBPMEMOBJ),n) +$(error libpmemobj(version >= $(LIBPMEMOBJ_MIN_VERSION)) is missing) +endif + +test_package: test_package.c + $(CC) test_package.c $(LIBS) $(CFLAGS) -o $@ + +clean: + rm -f test_package + +.PHONY: clean diff --git a/src/pmdk/utils/docker/test_package/README b/src/pmdk/utils/docker/test_package/README new file mode 100644 index 000000000..de81a6a5b --- /dev/null +++ b/src/pmdk/utils/docker/test_package/README @@ -0,0 +1,6 @@ +Persistent Memory Development Kit + +This is utils/docker/test_package/README. + +This directory contains simple application which uses libpmemobj. +It can be used to test whether libpmemobj was installed properly. diff --git a/src/pmdk/utils/docker/test_package/test_package.c b/src/pmdk/utils/docker/test_package/test_package.c new file mode 100644 index 000000000..cf1e7eb8b --- /dev/null +++ b/src/pmdk/utils/docker/test_package/test_package.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: BSD-3-Clause +/* Copyright 2018, Intel Corporation */ + +#include <libpmemobj.h> +#include <stdio.h> +#include <sys/stat.h> + +#define LAYOUT_NAME "test" + +struct my_root { + int foo; +}; + +int +main(int argc, char *argv[]) +{ + if (argc < 2) { + printf("usage: %s file-name\n", argv[0]); + return 1; + } + + const char *path = argv[1]; + + PMEMobjpool *pop = pmemobj_create(path, LAYOUT_NAME, + PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR); + + if (pop == NULL) { + printf("failed to create pool\n"); + return 1; + } + + PMEMoid root = pmemobj_root(pop, sizeof(struct my_root)); + struct my_root *rootp = pmemobj_direct(root); + + rootp->foo = 10; + pmemobj_persist(pop, &rootp->foo, sizeof(rootp->foo)); + + pmemobj_close(pop); + + return 0; +} |