repo
stringlengths
1
152
file
stringlengths
15
205
code
stringlengths
0
41.6M
file_length
int64
0
41.6M
avg_line_length
float64
0
1.81M
max_line_length
int64
0
12.7M
extension_type
stringclasses
90 values
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/librpmem/rpmem_cmd.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2019, Intel Corporation */ /* * rpmem_cmd.h -- helper module for invoking separate process */ #ifndef RPMEM_CMD_H #define RPMEM_CMD_H 1 #include <sys/types.h> #ifdef __cplusplus extern "C" { #endif struct rpmem_cmd { int fd_in; /* stdin */ int fd_out; /* stdout */ int fd_err; /* stderr */ struct { char **argv; int argc; } args; /* command arguments */ pid_t pid; /* pid of process */ }; struct rpmem_cmd *rpmem_cmd_init(void); int rpmem_cmd_push(struct rpmem_cmd *cmd, const char *arg); int rpmem_cmd_run(struct rpmem_cmd *cmd); void rpmem_cmd_term(struct rpmem_cmd *cmd); int rpmem_cmd_wait(struct rpmem_cmd *cmd, int *status); void rpmem_cmd_fini(struct rpmem_cmd *cmd); #ifdef __cplusplus } #endif #endif
790
18.775
61
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemblk/blk.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2014-2019, Intel Corporation */ /* * blk.h -- internal definitions for libpmem blk module */ #ifndef BLK_H #define BLK_H 1 #include <stddef.h> #include "ctl.h" #include "os_thread.h" #include "pool_hdr.h" #include "page_size.h" #ifdef __cplusplus extern "C" { #endif #include "alloc.h" #include "fault_injection.h" #define PMEMBLK_LOG_PREFIX "libpmemblk" #define PMEMBLK_LOG_LEVEL_VAR "PMEMBLK_LOG_LEVEL" #define PMEMBLK_LOG_FILE_VAR "PMEMBLK_LOG_FILE" /* attributes of the blk memory pool format for the pool header */ #define BLK_HDR_SIG "PMEMBLK" /* must be 8 bytes including '\0' */ #define BLK_FORMAT_MAJOR 1 #define BLK_FORMAT_FEAT_DEFAULT \ {POOL_FEAT_COMPAT_DEFAULT, POOL_FEAT_INCOMPAT_DEFAULT, 0x0000} #define BLK_FORMAT_FEAT_CHECK \ {POOL_FEAT_COMPAT_VALID, POOL_FEAT_INCOMPAT_VALID, 0x0000} static const features_t blk_format_feat_default = BLK_FORMAT_FEAT_DEFAULT; struct pmemblk { struct pool_hdr hdr; /* memory pool header */ /* root info for on-media format... */ uint32_t bsize; /* block size */ /* flag indicating if the pool was zero-initialized */ int is_zeroed; /* some run-time state, allocated out of memory pool... */ void *addr; /* mapped region */ size_t size; /* size of mapped region */ int is_pmem; /* true if pool is PMEM */ int rdonly; /* true if pool is opened read-only */ void *data; /* post-header data area */ size_t datasize; /* size of data area */ size_t nlba; /* number of LBAs in pool */ struct btt *bttp; /* btt handle */ unsigned nlane; /* number of lanes */ unsigned next_lane; /* used to rotate through lanes */ os_mutex_t *locks; /* one per lane */ int is_dev_dax; /* true if mapped on device dax */ struct ctl *ctl; /* top level node of the ctl tree structure */ struct pool_set *set; /* pool set info */ #ifdef DEBUG /* held during read/write mprotected sections */ os_mutex_t write_lock; #endif }; /* data area starts at this alignment after the struct pmemblk above */ #define BLK_FORMAT_DATA_ALIGN ((uintptr_t)PMEM_PAGESIZE) #if FAULT_INJECTION void pmemblk_inject_fault_at(enum pmem_allocation_type type, int nth, const char *at); int pmemblk_fault_injection_enabled(void); #else static inline void pmemblk_inject_fault_at(enum pmem_allocation_type type, int nth, const char *at) { abort(); } static inline int pmemblk_fault_injection_enabled(void) { return 0; } #endif #ifdef __cplusplus } #endif #endif
2,483
23.116505
74
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemblk/btt.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2014-2018, Intel Corporation */ /* * btt.h -- btt module definitions */ #ifndef BTT_H #define BTT_H 1 #ifdef __cplusplus extern "C" { #endif /* callback functions passed to btt_init() */ struct ns_callback { int (*nsread)(void *ns, unsigned lane, void *buf, size_t count, uint64_t off); int (*nswrite)(void *ns, unsigned lane, const void *buf, size_t count, uint64_t off); int (*nszero)(void *ns, unsigned lane, size_t count, uint64_t off); ssize_t (*nsmap)(void *ns, unsigned lane, void **addrp, size_t len, uint64_t off); void (*nssync)(void *ns, unsigned lane, void *addr, size_t len); int ns_is_zeroed; }; struct btt_info; struct btt *btt_init(uint64_t rawsize, uint32_t lbasize, uint8_t parent_uuid[], unsigned maxlane, void *ns, const struct ns_callback *ns_cbp); unsigned btt_nlane(struct btt *bttp); size_t btt_nlba(struct btt *bttp); int btt_read(struct btt *bttp, unsigned lane, uint64_t lba, void *buf); int btt_write(struct btt *bttp, unsigned lane, uint64_t lba, const void *buf); int btt_set_zero(struct btt *bttp, unsigned lane, uint64_t lba); int btt_set_error(struct btt *bttp, unsigned lane, uint64_t lba); int btt_check(struct btt *bttp); void btt_fini(struct btt *bttp); uint64_t btt_flog_size(uint32_t nfree); uint64_t btt_map_size(uint32_t external_nlba); uint64_t btt_arena_datasize(uint64_t arena_size, uint32_t nfree); int btt_info_set(struct btt_info *info, uint32_t external_lbasize, uint32_t nfree, uint64_t arena_size, uint64_t space_left); struct btt_flog *btt_flog_get_valid(struct btt_flog *flog_pair, int *next); int map_entry_is_initial(uint32_t map_entry); void btt_info_convert2h(struct btt_info *infop); void btt_info_convert2le(struct btt_info *infop); void btt_flog_convert2h(struct btt_flog *flogp); void btt_flog_convert2le(struct btt_flog *flogp); #ifdef __cplusplus } #endif #endif
1,908
30.816667
79
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemblk/btt_layout.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2014-2018, Intel Corporation */ /* * btt_layout.h -- block translation table on-media layout definitions */ /* * Layout of BTT info block. All integers are stored little-endian. */ #ifndef BTT_LAYOUT_H #define BTT_LAYOUT_H 1 #ifdef __cplusplus extern "C" { #endif #define BTT_ALIGNMENT ((uintptr_t)4096) /* alignment of all BTT structures */ #define BTTINFO_SIG_LEN 16 #define BTTINFO_UUID_LEN 16 #define BTTINFO_UNUSED_LEN 3968 #define BTTINFO_SIG "BTT_ARENA_INFO\0" struct btt_info { char sig[BTTINFO_SIG_LEN]; /* must be "BTT_ARENA_INFO\0\0" */ uint8_t uuid[BTTINFO_UUID_LEN]; /* BTT UUID */ uint8_t parent_uuid[BTTINFO_UUID_LEN]; /* UUID of container */ uint32_t flags; /* see flag bits below */ uint16_t major; /* major version */ uint16_t minor; /* minor version */ uint32_t external_lbasize; /* advertised LBA size (bytes) */ uint32_t external_nlba; /* advertised LBAs in this arena */ uint32_t internal_lbasize; /* size of data area blocks (bytes) */ uint32_t internal_nlba; /* number of blocks in data area */ uint32_t nfree; /* number of free blocks */ uint32_t infosize; /* size of this info block */ /* * The following offsets are relative to the beginning of * the btt_info block. */ uint64_t nextoff; /* offset to next arena (or zero) */ uint64_t dataoff; /* offset to arena data area */ uint64_t mapoff; /* offset to area map */ uint64_t flogoff; /* offset to area flog */ uint64_t infooff; /* offset to backup info block */ char unused[BTTINFO_UNUSED_LEN]; /* must be zero */ uint64_t checksum; /* Fletcher64 of all fields */ }; /* * Definitions for flags mask for btt_info structure above. */ #define BTTINFO_FLAG_ERROR 0x00000001 /* error state (read-only) */ #define BTTINFO_FLAG_ERROR_MASK 0x00000001 /* all error bits */ /* * Current on-media format versions. */ #define BTTINFO_MAJOR_VERSION 1 #define BTTINFO_MINOR_VERSION 1 /* * Layout of a BTT "flog" entry. All integers are stored little-endian. * * The "nfree" field in the BTT info block determines how many of these * flog entries there are, and each entry consists of two of the following * structs (entry updates alternate between the two structs), padded up * to a cache line boundary to isolate adjacent updates. */ #define BTT_FLOG_PAIR_ALIGN ((uintptr_t)64) struct btt_flog { uint32_t lba; /* last pre-map LBA using this entry */ uint32_t old_map; /* old post-map LBA (the freed block) */ uint32_t new_map; /* new post-map LBA */ uint32_t seq; /* sequence number (01, 10, 11) */ }; /* * Layout of a BTT "map" entry. 4-byte internal LBA offset, little-endian. */ #define BTT_MAP_ENTRY_SIZE 4 #define BTT_MAP_ENTRY_ERROR 0x40000000U #define BTT_MAP_ENTRY_ZERO 0x80000000U #define BTT_MAP_ENTRY_NORMAL 0xC0000000U #define BTT_MAP_ENTRY_LBA_MASK 0x3fffffffU #define BTT_MAP_LOCK_ALIGN ((uintptr_t)64) /* * BTT layout properties... */ #define BTT_MIN_SIZE ((1u << 20) * 16) #define BTT_MAX_ARENA (1ull << 39) /* 512GB per arena */ #define BTT_MIN_LBA_SIZE (size_t)512 #define BTT_INTERNAL_LBA_ALIGNMENT 256U #define BTT_DEFAULT_NFREE 256 #ifdef __cplusplus } #endif #endif
3,197
28.611111
77
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/heap_layout.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2018, Intel Corporation */ /* * heap_layout.h -- internal definitions for heap layout */ #ifndef LIBPMEMOBJ_HEAP_LAYOUT_H #define LIBPMEMOBJ_HEAP_LAYOUT_H 1 #include <stddef.h> #include <stdint.h> #ifdef __cplusplus extern "C" { #endif #define HEAP_MAJOR 1 #define HEAP_MINOR 0 #define MAX_CHUNK (UINT16_MAX - 7) /* has to be multiple of 8 */ #define CHUNK_BASE_ALIGNMENT 1024 #define CHUNKSIZE ((size_t)1024 * 256) /* 256 kilobytes */ #define MAX_MEMORY_BLOCK_SIZE (MAX_CHUNK * CHUNKSIZE) #define HEAP_SIGNATURE_LEN 16 #define HEAP_SIGNATURE "MEMORY_HEAP_HDR\0" #define ZONE_HEADER_MAGIC 0xC3F0A2D2 #define ZONE_MIN_SIZE (sizeof(struct zone) + sizeof(struct chunk)) #define ZONE_MAX_SIZE (sizeof(struct zone) + sizeof(struct chunk) * MAX_CHUNK) #define HEAP_MIN_SIZE (sizeof(struct heap_layout) + ZONE_MIN_SIZE) /* Base bitmap values, relevant for both normal and flexible bitmaps */ #define RUN_BITS_PER_VALUE 64U #define RUN_BASE_METADATA_VALUES\ ((unsigned)(sizeof(struct chunk_run_header) / sizeof(uint64_t))) #define RUN_BASE_METADATA_SIZE (sizeof(struct chunk_run_header)) #define RUN_CONTENT_SIZE (CHUNKSIZE - RUN_BASE_METADATA_SIZE) /* * Calculates the size in bytes of a single run instance, including bitmap */ #define RUN_CONTENT_SIZE_BYTES(size_idx)\ (RUN_CONTENT_SIZE + (((size_idx) - 1) * CHUNKSIZE)) /* Default bitmap values, specific for old, non-flexible, bitmaps */ #define RUN_DEFAULT_METADATA_VALUES 40 /* in 8 byte words, 320 bytes total */ #define RUN_DEFAULT_BITMAP_VALUES \ (RUN_DEFAULT_METADATA_VALUES - RUN_BASE_METADATA_VALUES) #define RUN_DEFAULT_BITMAP_SIZE (sizeof(uint64_t) * RUN_DEFAULT_BITMAP_VALUES) #define RUN_DEFAULT_BITMAP_NBITS\ (RUN_BITS_PER_VALUE * RUN_DEFAULT_BITMAP_VALUES) #define RUN_DEFAULT_SIZE \ (CHUNKSIZE - RUN_BASE_METADATA_SIZE - RUN_DEFAULT_BITMAP_SIZE) /* * Calculates the size in bytes of a single run instance, without bitmap, * but only for the default fixed-bitmap algorithm */ #define RUN_DEFAULT_SIZE_BYTES(size_idx)\ (RUN_DEFAULT_SIZE + (((size_idx) - 1) * CHUNKSIZE)) #define CHUNK_MASK ((CHUNKSIZE) - 1) #define CHUNK_ALIGN_UP(value) ((((value) + CHUNK_MASK) & ~CHUNK_MASK)) enum chunk_flags { CHUNK_FLAG_COMPACT_HEADER = 0x0001, CHUNK_FLAG_HEADER_NONE = 0x0002, CHUNK_FLAG_ALIGNED = 0x0004, CHUNK_FLAG_FLEX_BITMAP = 0x0008, }; #define CHUNK_FLAGS_ALL_VALID (\ CHUNK_FLAG_COMPACT_HEADER |\ CHUNK_FLAG_HEADER_NONE |\ CHUNK_FLAG_ALIGNED |\ CHUNK_FLAG_FLEX_BITMAP\ ) enum chunk_type { CHUNK_TYPE_UNKNOWN, CHUNK_TYPE_FOOTER, /* not actual chunk type */ CHUNK_TYPE_FREE, CHUNK_TYPE_USED, CHUNK_TYPE_RUN, CHUNK_TYPE_RUN_DATA, MAX_CHUNK_TYPE }; struct chunk { uint8_t data[CHUNKSIZE]; }; struct chunk_run_header { uint64_t block_size; uint64_t alignment; /* valid only /w CHUNK_FLAG_ALIGNED */ }; struct chunk_run { struct chunk_run_header hdr; uint8_t content[RUN_CONTENT_SIZE]; /* bitmap + data */ }; struct chunk_header { uint16_t type; uint16_t flags; uint32_t size_idx; }; struct zone_header { uint32_t magic; uint32_t size_idx; uint8_t reserved[56]; }; struct zone { struct zone_header header; struct chunk_header chunk_headers[MAX_CHUNK]; struct chunk chunks[]; }; struct heap_header { char signature[HEAP_SIGNATURE_LEN]; uint64_t major; uint64_t minor; uint64_t unused; /* might be garbage */ uint64_t chunksize; uint64_t chunks_per_zone; uint8_t reserved[960]; uint64_t checksum; }; struct heap_layout { struct heap_header header; struct zone zone0; /* first element of zones array */ }; #define ALLOC_HDR_SIZE_SHIFT (48ULL) #define ALLOC_HDR_FLAGS_MASK (((1ULL) << ALLOC_HDR_SIZE_SHIFT) - 1) struct allocation_header_legacy { uint8_t unused[8]; uint64_t size; uint8_t unused2[32]; uint64_t root_size; uint64_t type_num; }; #define ALLOC_HDR_COMPACT_SIZE sizeof(struct allocation_header_compact) struct allocation_header_compact { uint64_t size; uint64_t extra; }; enum header_type { HEADER_LEGACY, HEADER_COMPACT, HEADER_NONE, MAX_HEADER_TYPES }; static const size_t header_type_to_size[MAX_HEADER_TYPES] = { sizeof(struct allocation_header_legacy), sizeof(struct allocation_header_compact), 0 }; static const enum chunk_flags header_type_to_flag[MAX_HEADER_TYPES] = { (enum chunk_flags)0, CHUNK_FLAG_COMPACT_HEADER, CHUNK_FLAG_HEADER_NONE }; static inline struct zone * ZID_TO_ZONE(struct heap_layout *layout, size_t zone_id) { return (struct zone *) ((uintptr_t)&layout->zone0 + ZONE_MAX_SIZE * zone_id); } static inline struct chunk_header * GET_CHUNK_HDR(struct heap_layout *layout, size_t zone_id, unsigned chunk_id) { return &ZID_TO_ZONE(layout, zone_id)->chunk_headers[chunk_id]; } static inline struct chunk * GET_CHUNK(struct heap_layout *layout, size_t zone_id, unsigned chunk_id) { return &ZID_TO_ZONE(layout, zone_id)->chunks[chunk_id]; } static inline struct chunk_run * GET_CHUNK_RUN(struct heap_layout *layout, size_t zone_id, unsigned chunk_id) { return (struct chunk_run *)GET_CHUNK(layout, zone_id, chunk_id); } #ifdef __cplusplus } #endif #endif
5,105
23.666667
78
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/alloc_class.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2020, Intel Corporation */ /* * alloc_class.h -- internal definitions for allocation classes */ #ifndef LIBPMEMOBJ_ALLOC_CLASS_H #define LIBPMEMOBJ_ALLOC_CLASS_H 1 #include <stddef.h> #include <stdint.h> #include <sys/types.h> #include "heap_layout.h" #include "memblock.h" #ifdef __cplusplus extern "C" { #endif #define MAX_ALLOCATION_CLASSES (UINT8_MAX) #define DEFAULT_ALLOC_CLASS_ID (0) #define RUN_UNIT_MAX RUN_BITS_PER_VALUE struct alloc_class_collection; enum alloc_class_type { CLASS_UNKNOWN, CLASS_HUGE, CLASS_RUN, MAX_ALLOC_CLASS_TYPES }; struct alloc_class { uint8_t id; uint16_t flags; size_t unit_size; enum header_type header_type; enum alloc_class_type type; /* run-specific data */ struct run_descriptor rdsc; }; struct alloc_class_collection *alloc_class_collection_new(void); void alloc_class_collection_delete(struct alloc_class_collection *ac); struct alloc_class *alloc_class_by_run( struct alloc_class_collection *ac, size_t unit_size, uint16_t flags, uint32_t size_idx); struct alloc_class *alloc_class_by_alloc_size( struct alloc_class_collection *ac, size_t size); struct alloc_class *alloc_class_by_id( struct alloc_class_collection *ac, uint8_t id); int alloc_class_reserve(struct alloc_class_collection *ac, uint8_t id); int alloc_class_find_first_free_slot(struct alloc_class_collection *ac, uint8_t *slot); ssize_t alloc_class_calc_size_idx(struct alloc_class *c, size_t size); struct alloc_class * alloc_class_new(int id, struct alloc_class_collection *ac, enum alloc_class_type type, enum header_type htype, size_t unit_size, size_t alignment, uint32_t size_idx); void alloc_class_delete(struct alloc_class_collection *ac, struct alloc_class *c); #ifdef __cplusplus } #endif #endif
1,815
21.7
71
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/container_seglists.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2018, Intel Corporation */ /* * container_seglists.h -- internal definitions for * segregated lists block container */ #ifndef LIBPMEMOBJ_CONTAINER_SEGLISTS_H #define LIBPMEMOBJ_CONTAINER_SEGLISTS_H 1 #include "container.h" #ifdef __cplusplus extern "C" { #endif struct block_container *container_new_seglists(struct palloc_heap *heap); #ifdef __cplusplus } #endif #endif /* LIBPMEMOBJ_CONTAINER_SEGLISTS_H */
479
18.2
73
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/obj.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2014-2020, Intel Corporation */ /* * obj.h -- internal definitions for obj module */ #ifndef LIBPMEMOBJ_OBJ_H #define LIBPMEMOBJ_OBJ_H 1 #include <stddef.h> #include <stdint.h> #include "lane.h" #include "pool_hdr.h" #include "pmalloc.h" #include "ctl.h" #include "sync.h" #include "stats.h" #include "ctl_debug.h" #include "page_size.h" #ifdef __cplusplus extern "C" { #endif #include "alloc.h" #include "fault_injection.h" #define PMEMOBJ_LOG_PREFIX "libpmemobj" #define PMEMOBJ_LOG_LEVEL_VAR "PMEMOBJ_LOG_LEVEL" #define PMEMOBJ_LOG_FILE_VAR "PMEMOBJ_LOG_FILE" /* attributes of the obj memory pool format for the pool header */ #define OBJ_HDR_SIG "PMEMOBJ" /* must be 8 bytes including '\0' */ #define OBJ_FORMAT_MAJOR 6 #define OBJ_FORMAT_FEAT_DEFAULT \ {POOL_FEAT_COMPAT_DEFAULT, POOL_FEAT_INCOMPAT_DEFAULT, 0x0000} #define OBJ_FORMAT_FEAT_CHECK \ {POOL_FEAT_COMPAT_VALID, POOL_FEAT_INCOMPAT_VALID, 0x0000} static const features_t obj_format_feat_default = OBJ_FORMAT_FEAT_CHECK; /* size of the persistent part of PMEMOBJ pool descriptor */ #define OBJ_DSC_P_SIZE 2048 /* size of unused part of the persistent part of PMEMOBJ pool descriptor */ #define OBJ_DSC_P_UNUSED (OBJ_DSC_P_SIZE - PMEMOBJ_MAX_LAYOUT - 40) #define OBJ_LANES_OFFSET (sizeof(struct pmemobjpool)) /* lanes offset */ #define OBJ_NLANES 1024 /* number of lanes */ #define OBJ_OFF_TO_PTR(pop, off) ((void *)((uintptr_t)(pop) + (off))) #define OBJ_PTR_TO_OFF(pop, ptr) ((uintptr_t)(ptr) - (uintptr_t)(pop)) #define OBJ_OID_IS_NULL(oid) ((oid).off == 0) #define OBJ_LIST_EMPTY(head) OBJ_OID_IS_NULL((head)->pe_first) #define OBJ_OFF_FROM_HEAP(pop, off)\ ((off) >= (pop)->heap_offset &&\ (off) < (pop)->heap_offset + (pop)->heap_size) #define OBJ_OFF_FROM_LANES(pop, off)\ ((off) >= (pop)->lanes_offset &&\ (off) < (pop)->lanes_offset +\ (pop)->nlanes * sizeof(struct lane_layout)) #define OBJ_PTR_FROM_POOL(pop, ptr)\ ((uintptr_t)(ptr) >= (uintptr_t)(pop) &&\ (uintptr_t)(ptr) < (uintptr_t)(pop) +\ (pop)->heap_offset + (pop)->heap_size) #define OBJ_OFF_IS_VALID(pop, off)\ (OBJ_OFF_FROM_HEAP(pop, off) ||\ (OBJ_PTR_TO_OFF(pop, &(pop)->root_offset) == (off)) ||\ (OBJ_PTR_TO_OFF(pop, &(pop)->root_size) == (off)) ||\ (OBJ_OFF_FROM_LANES(pop, off))) #define OBJ_PTR_IS_VALID(pop, ptr)\ OBJ_OFF_IS_VALID(pop, OBJ_PTR_TO_OFF(pop, ptr)) typedef void (*persist_local_fn)(const void *, size_t); typedef void (*flush_local_fn)(const void *, size_t); typedef void (*drain_local_fn)(void); typedef void *(*memcpy_local_fn)(void *dest, const void *src, size_t len, unsigned flags); typedef void *(*memmove_local_fn)(void *dest, const void *src, size_t len, unsigned flags); typedef void *(*memset_local_fn)(void *dest, int c, size_t len, unsigned flags); typedef int (*persist_remote_fn)(PMEMobjpool *pop, const void *addr, size_t len, unsigned lane, unsigned flags); typedef uint64_t type_num_t; #define CONVERSION_FLAG_OLD_SET_CACHE ((1ULL) << 0) /* PMEM_OBJ_POOL_HEAD_SIZE Without the unused and unused2 arrays */ #define PMEM_OBJ_POOL_HEAD_SIZE 2196 #define PMEM_OBJ_POOL_UNUSED2_SIZE (PMEM_PAGESIZE \ - OBJ_DSC_P_UNUSED\ - PMEM_OBJ_POOL_HEAD_SIZE) /* //NEW //#define _GNU_SOURCE //#include <sys/types.h> //#include <sys/stat.h> #include <fcntl.h> #include <sys/mman.h> //int __real_open(const char *__path, int __oflag); //int __wrap_open(const char *__path, int __oflag); void* open_device(void); //END NEW */ struct pmemobjpool { struct pool_hdr hdr; /* memory pool header */ /* persistent part of PMEMOBJ pool descriptor (2kB) */ char layout[PMEMOBJ_MAX_LAYOUT]; uint64_t lanes_offset; uint64_t nlanes; uint64_t heap_offset; uint64_t unused3; unsigned char unused[OBJ_DSC_P_UNUSED]; /* must be zero */ uint64_t checksum; /* checksum of above fields */ uint64_t root_offset; /* unique runID for this program run - persistent but not checksummed */ uint64_t run_id; uint64_t root_size; /* * These flags can be set from a conversion tool and are set only for * the first recovery of the pool. */ uint64_t conversion_flags; uint64_t heap_size; struct stats_persistent stats_persistent; char pmem_reserved[496]; /* must be zeroed */ /* some run-time state, allocated out of memory pool... */ void *addr; /* mapped region */ int is_pmem; /* true if pool is PMEM */ int rdonly; /* true if pool is opened read-only */ struct palloc_heap heap; struct lane_descriptor lanes_desc; uint64_t uuid_lo; int is_dev_dax; /* true if mapped on device dax */ struct ctl *ctl; /* top level node of the ctl tree structure */ struct stats *stats; struct pool_set *set; /* pool set info */ struct pmemobjpool *replica; /* next replica */ /* per-replica functions: pmem or non-pmem */ persist_local_fn persist_local; /* persist function */ flush_local_fn flush_local; /* flush function */ drain_local_fn drain_local; /* drain function */ memcpy_local_fn memcpy_local; /* persistent memcpy function */ memmove_local_fn memmove_local; /* persistent memmove function */ memset_local_fn memset_local; /* persistent memset function */ /* for 'master' replica: with or without data replication */ struct pmem_ops p_ops; PMEMmutex rootlock; /* root object lock */ int is_master_replica; int has_remote_replicas; /* remote replica section */ void *rpp; /* RPMEMpool opaque handle if it is a remote replica */ uintptr_t remote_base; /* beginning of the remote pool */ char *node_addr; /* address of a remote node */ char *pool_desc; /* descriptor of a poolset */ persist_remote_fn persist_remote; /* remote persist function */ int vg_boot; int tx_debug_skip_expensive_checks; struct tx_parameters *tx_params; /* * Locks are dynamically allocated on FreeBSD. Keep track so * we can free them on pmemobj_close. */ PMEMmutex_internal *mutex_head; PMEMrwlock_internal *rwlock_head; PMEMcond_internal *cond_head; struct { struct ravl *map; os_mutex_t lock; int verify; } ulog_user_buffers; void *user_data; //New //void *device; /* padding to align size of this structure to page boundary */ /* sizeof(unused2) == 8192 - offsetof(struct pmemobjpool, unused2) */ char unused2[PMEM_OBJ_POOL_UNUSED2_SIZE -28 ]; }; /* * Stored in the 'size' field of oobh header, determines whether the object * is internal or not. Internal objects are skipped in pmemobj iteration * functions. */ #define OBJ_INTERNAL_OBJECT_MASK ((1ULL) << 15) #define CLASS_ID_FROM_FLAG(flag)\ ((uint16_t)((flag) >> 48)) #define ARENA_ID_FROM_FLAG(flag)\ ((uint16_t)((flag) >> 32)) /* * pmemobj_get_uuid_lo -- (internal) evaluates XOR sum of least significant * 8 bytes with most significant 8 bytes. */ static inline uint64_t pmemobj_get_uuid_lo(PMEMobjpool *pop) { uint64_t uuid_lo = 0; for (int i = 0; i < 8; i++) { uuid_lo = (uuid_lo << 8) | (pop->hdr.poolset_uuid[i] ^ pop->hdr.poolset_uuid[8 + i]); } return uuid_lo; } /* * OBJ_OID_IS_VALID -- (internal) checks if 'oid' is valid */ static inline int OBJ_OID_IS_VALID(PMEMobjpool *pop, PMEMoid oid) { return OBJ_OID_IS_NULL(oid) || (oid.pool_uuid_lo == pop->uuid_lo && oid.off >= pop->heap_offset && oid.off < pop->heap_offset + pop->heap_size); } static inline int OBJ_OFF_IS_VALID_FROM_CTX(void *ctx, uint64_t offset) { PMEMobjpool *pop = (PMEMobjpool *)ctx; return OBJ_OFF_IS_VALID(pop, offset); } void obj_init(void); void obj_fini(void); int obj_read_remote(void *ctx, uintptr_t base, void *dest, void *addr, size_t length); /* * (debug helper macro) logs notice message if used inside a transaction */ #ifdef DEBUG #define _POBJ_DEBUG_NOTICE_IN_TX()\ _pobj_debug_notice(__func__, NULL, 0) #else #define _POBJ_DEBUG_NOTICE_IN_TX() do {} while (0) #endif #if FAULT_INJECTION void pmemobj_inject_fault_at(enum pmem_allocation_type type, int nth, const char *at); int pmemobj_fault_injection_enabled(void); #else static inline void pmemobj_inject_fault_at(enum pmem_allocation_type type, int nth, const char *at) { abort(); } static inline int pmemobj_fault_injection_enabled(void) { return 0; } #endif #ifdef __cplusplus } #endif #endif
8,196
25.441935
80
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/list.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2018, Intel Corporation */ /* * list.h -- internal definitions for persistent atomic lists module */ #ifndef LIBPMEMOBJ_LIST_H #define LIBPMEMOBJ_LIST_H 1 #include <stddef.h> #include <stdint.h> #include <sys/types.h> #include "libpmemobj.h" #include "lane.h" #include "pmalloc.h" #include "ulog.h" #ifdef __cplusplus extern "C" { #endif struct list_entry { PMEMoid pe_next; PMEMoid pe_prev; }; struct list_head { PMEMoid pe_first; PMEMmutex lock; }; int list_insert_new_user(PMEMobjpool *pop, size_t pe_offset, struct list_head *user_head, PMEMoid dest, int before, size_t size, uint64_t type_num, palloc_constr constructor, void *arg, PMEMoid *oidp); int list_insert(PMEMobjpool *pop, ssize_t pe_offset, struct list_head *head, PMEMoid dest, int before, PMEMoid oid); int list_remove_free_user(PMEMobjpool *pop, size_t pe_offset, struct list_head *user_head, PMEMoid *oidp); int list_remove(PMEMobjpool *pop, ssize_t pe_offset, struct list_head *head, PMEMoid oid); int list_move(PMEMobjpool *pop, size_t pe_offset_old, struct list_head *head_old, size_t pe_offset_new, struct list_head *head_new, PMEMoid dest, int before, PMEMoid oid); void list_move_oob(PMEMobjpool *pop, struct list_head *head_old, struct list_head *head_new, PMEMoid oid); #ifdef __cplusplus } #endif #endif
1,376
20.184615
73
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/ctl_debug.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2018, Intel Corporation */ /* * ctl_debug.h -- definitions for the debug CTL namespace */ #ifndef LIBPMEMOBJ_CTL_DEBUG_H #define LIBPMEMOBJ_CTL_DEBUG_H 1 #include "libpmemobj.h" #ifdef __cplusplus extern "C" { #endif void debug_ctl_register(PMEMobjpool *pop); #ifdef __cplusplus } #endif #endif /* LIBPMEMOBJ_CTL_DEBUG_H */
386
15.826087
57
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/heap.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2019, Intel Corporation */ /* * heap.h -- internal definitions for heap */ #ifndef LIBPMEMOBJ_HEAP_H #define LIBPMEMOBJ_HEAP_H 1 #include <stddef.h> #include <stdint.h> #include "bucket.h" #include "memblock.h" #include "memops.h" #include "palloc.h" #include "os_thread.h" #ifdef __cplusplus extern "C" { #endif #define HEAP_OFF_TO_PTR(heap, off) ((void *)((char *)((heap)->base) + (off))) #define HEAP_PTR_TO_OFF(heap, ptr)\ ((uintptr_t)(ptr) - (uintptr_t)((heap)->base)) #define BIT_IS_CLR(a, i) (!((a) & (1ULL << (i)))) #define HEAP_ARENA_PER_THREAD (0) int heap_boot(struct palloc_heap *heap, void *heap_start, uint64_t heap_size, uint64_t *sizep, void *base, struct pmem_ops *p_ops, struct stats *stats, struct pool_set *set); int heap_init(void *heap_start, uint64_t heap_size, uint64_t *sizep, struct pmem_ops *p_ops); void heap_cleanup(struct palloc_heap *heap); int heap_check(void *heap_start, uint64_t heap_size); int heap_check_remote(void *heap_start, uint64_t heap_size, struct remote_ops *ops); int heap_buckets_init(struct palloc_heap *heap); int heap_create_alloc_class_buckets(struct palloc_heap *heap, struct alloc_class *c); int heap_extend(struct palloc_heap *heap, struct bucket *defb, size_t size); struct alloc_class * heap_get_best_class(struct palloc_heap *heap, size_t size); struct bucket * heap_bucket_acquire(struct palloc_heap *heap, uint8_t class_id, uint16_t arena_id); void heap_bucket_release(struct palloc_heap *heap, struct bucket *b); int heap_get_bestfit_block(struct palloc_heap *heap, struct bucket *b, struct memory_block *m); struct memory_block heap_coalesce_huge(struct palloc_heap *heap, struct bucket *b, const struct memory_block *m); os_mutex_t *heap_get_run_lock(struct palloc_heap *heap, uint32_t chunk_id); void heap_force_recycle(struct palloc_heap *heap); void heap_discard_run(struct palloc_heap *heap, struct memory_block *m); void heap_memblock_on_free(struct palloc_heap *heap, const struct memory_block *m); int heap_free_chunk_reuse(struct palloc_heap *heap, struct bucket *bucket, struct memory_block *m); void heap_foreach_object(struct palloc_heap *heap, object_callback cb, void *arg, struct memory_block start); struct alloc_class_collection *heap_alloc_classes(struct palloc_heap *heap); void *heap_end(struct palloc_heap *heap); unsigned heap_get_narenas_total(struct palloc_heap *heap); unsigned heap_get_narenas_max(struct palloc_heap *heap); int heap_set_narenas_max(struct palloc_heap *heap, unsigned size); unsigned heap_get_narenas_auto(struct palloc_heap *heap); unsigned heap_get_thread_arena_id(struct palloc_heap *heap); int heap_arena_create(struct palloc_heap *heap); struct bucket ** heap_get_arena_buckets(struct palloc_heap *heap, unsigned arena_id); int heap_get_arena_auto(struct palloc_heap *heap, unsigned arena_id); int heap_set_arena_auto(struct palloc_heap *heap, unsigned arena_id, int automatic); void heap_set_arena_thread(struct palloc_heap *heap, unsigned arena_id); void heap_vg_open(struct palloc_heap *heap, object_callback cb, void *arg, int objects); static inline struct chunk_header * heap_get_chunk_hdr(struct palloc_heap *heap, const struct memory_block *m) { return GET_CHUNK_HDR(heap->layout, m->zone_id, m->chunk_id); } static inline struct chunk * heap_get_chunk(struct palloc_heap *heap, const struct memory_block *m) { return GET_CHUNK(heap->layout, m->zone_id, m->chunk_id); } static inline struct chunk_run * heap_get_chunk_run(struct palloc_heap *heap, const struct memory_block *m) { return GET_CHUNK_RUN(heap->layout, m->zone_id, m->chunk_id); } #ifdef __cplusplus } #endif #endif
3,719
26.969925
78
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/memops.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2019, Intel Corporation */ /* * memops.h -- aggregated memory operations helper definitions */ #ifndef LIBPMEMOBJ_MEMOPS_H #define LIBPMEMOBJ_MEMOPS_H 1 #include <stddef.h> #include <stdint.h> #include "vec.h" #include "pmemops.h" #include "ulog.h" #include "lane.h" #ifdef __cplusplus extern "C" { #endif enum operation_log_type { LOG_PERSISTENT, /* log of persistent modifications */ LOG_TRANSIENT, /* log of transient memory modifications */ MAX_OPERATION_LOG_TYPE }; enum log_type { LOG_TYPE_UNDO, LOG_TYPE_REDO, MAX_LOG_TYPE, }; struct user_buffer_def { void *addr; size_t size; }; #ifdef GET_NDP_BREAKDOWN extern uint64_t ulogCycles; #endif #ifdef USE_NDP_REDO extern int use_ndp_redo; #endif struct operation_context; struct operation_context * operation_new(struct ulog *redo, size_t ulog_base_nbytes, ulog_extend_fn extend, ulog_free_fn ulog_free, const struct pmem_ops *p_ops, enum log_type type); void operation_init(struct operation_context *ctx); void operation_start(struct operation_context *ctx); void operation_resume(struct operation_context *ctx); void operation_delete(struct operation_context *ctx); void operation_free_logs(struct operation_context *ctx, uint64_t flags); int operation_add_buffer(struct operation_context *ctx, void *dest, void *src, size_t size, ulog_operation_type type); int operation_add_entry(struct operation_context *ctx, void *ptr, uint64_t value, ulog_operation_type type); int operation_add_typed_entry(struct operation_context *ctx, void *ptr, uint64_t value, ulog_operation_type type, enum operation_log_type log_type); int operation_user_buffer_verify_align(struct operation_context *ctx, struct user_buffer_def *userbuf); void operation_add_user_buffer(struct operation_context *ctx, struct user_buffer_def *userbuf); void operation_set_auto_reserve(struct operation_context *ctx, int auto_reserve); void operation_set_any_user_buffer(struct operation_context *ctx, int any_user_buffer); int operation_get_any_user_buffer(struct operation_context *ctx); int operation_user_buffer_range_cmp(const void *lhs, const void *rhs); int operation_reserve(struct operation_context *ctx, size_t new_capacity); void operation_process(struct operation_context *ctx); void operation_finish(struct operation_context *ctx, unsigned flags); void operation_cancel(struct operation_context *ctx); #ifdef __cplusplus } #endif #endif
2,467
26.422222
74
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/pmalloc.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2018, Intel Corporation */ /* * pmalloc.h -- internal definitions for persistent malloc */ #ifndef LIBPMEMOBJ_PMALLOC_H #define LIBPMEMOBJ_PMALLOC_H 1 #include <stddef.h> #include <stdint.h> #include "libpmemobj.h" #include "memops.h" #include "palloc.h" #ifdef __cplusplus extern "C" { #endif /* single operations done in the internal context of the lane */ int pmalloc(PMEMobjpool *pop, uint64_t *off, size_t size, uint64_t extra_field, uint16_t object_flags); int pmalloc_construct(PMEMobjpool *pop, uint64_t *off, size_t size, palloc_constr constructor, void *arg, uint64_t extra_field, uint16_t object_flags, uint16_t class_id); int prealloc(PMEMobjpool *pop, uint64_t *off, size_t size, uint64_t extra_field, uint16_t object_flags); void pfree(PMEMobjpool *pop, uint64_t *off); /* external operation to be used together with context-aware palloc funcs */ struct operation_context *pmalloc_operation_hold(PMEMobjpool *pop); struct operation_context *pmalloc_operation_hold_no_start(PMEMobjpool *pop); void pmalloc_operation_release(PMEMobjpool *pop); void pmalloc_ctl_register(PMEMobjpool *pop); int pmalloc_cleanup(PMEMobjpool *pop); int pmalloc_boot(PMEMobjpool *pop); #ifdef __cplusplus } #endif #endif
1,291
24.333333
76
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/recycler.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2019, Intel Corporation */ /* * recycler.h -- internal definitions of run recycler * * This is a container that stores runs that are currently not used by any of * the buckets. */ #ifndef LIBPMEMOBJ_RECYCLER_H #define LIBPMEMOBJ_RECYCLER_H 1 #include "memblock.h" #include "vec.h" #ifdef __cplusplus extern "C" { #endif struct recycler; VEC(empty_runs, struct memory_block); struct recycler_element { uint32_t max_free_block; uint32_t free_space; uint32_t chunk_id; uint32_t zone_id; }; struct recycler *recycler_new(struct palloc_heap *layout, size_t nallocs, size_t *peak_arenas); void recycler_delete(struct recycler *r); struct recycler_element recycler_element_new(struct palloc_heap *heap, const struct memory_block *m); int recycler_put(struct recycler *r, const struct memory_block *m, struct recycler_element element); int recycler_get(struct recycler *r, struct memory_block *m); struct empty_runs recycler_recalc(struct recycler *r, int force); void recycler_inc_unaccounted(struct recycler *r, const struct memory_block *m); #ifdef __cplusplus } #endif #endif
1,158
20.867925
77
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/palloc.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2019, Intel Corporation */ /* * palloc.h -- internal definitions for persistent allocator */ #ifndef LIBPMEMOBJ_PALLOC_H #define LIBPMEMOBJ_PALLOC_H 1 #include <stddef.h> #include <stdint.h> #include "libpmemobj.h" #include "memops.h" #include "ulog.h" #include "valgrind_internal.h" #include "stats.h" #ifdef __cplusplus extern "C" { #endif #define PALLOC_CTL_DEBUG_NO_PATTERN (-1) struct palloc_heap { struct pmem_ops p_ops; struct heap_layout *layout; struct heap_rt *rt; uint64_t *sizep; uint64_t growsize; struct stats *stats; struct pool_set *set; void *base; int alloc_pattern; }; struct memory_block; typedef int (*palloc_constr)(void *base, void *ptr, size_t usable_size, void *arg); int palloc_operation(struct palloc_heap *heap, uint64_t off, uint64_t *dest_off, size_t size, palloc_constr constructor, void *arg, uint64_t extra_field, uint16_t object_flags, uint16_t class_id, uint16_t arena_id, struct operation_context *ctx); int palloc_reserve(struct palloc_heap *heap, size_t size, palloc_constr constructor, void *arg, uint64_t extra_field, uint16_t object_flags, uint16_t class_id, uint16_t arena_id, struct pobj_action *act); void palloc_defer_free(struct palloc_heap *heap, uint64_t off, struct pobj_action *act); void palloc_cancel(struct palloc_heap *heap, struct pobj_action *actv, size_t actvcnt); void palloc_publish(struct palloc_heap *heap, struct pobj_action *actv, size_t actvcnt, struct operation_context *ctx); void palloc_set_value(struct palloc_heap *heap, struct pobj_action *act, uint64_t *ptr, uint64_t value); uint64_t palloc_first(struct palloc_heap *heap); uint64_t palloc_next(struct palloc_heap *heap, uint64_t off); size_t palloc_usable_size(struct palloc_heap *heap, uint64_t off); uint64_t palloc_extra(struct palloc_heap *heap, uint64_t off); uint16_t palloc_flags(struct palloc_heap *heap, uint64_t off); int palloc_boot(struct palloc_heap *heap, void *heap_start, uint64_t heap_size, uint64_t *sizep, void *base, struct pmem_ops *p_ops, struct stats *stats, struct pool_set *set); int palloc_buckets_init(struct palloc_heap *heap); int palloc_init(void *heap_start, uint64_t heap_size, uint64_t *sizep, struct pmem_ops *p_ops); void *palloc_heap_end(struct palloc_heap *h); int palloc_heap_check(void *heap_start, uint64_t heap_size); int palloc_heap_check_remote(void *heap_start, uint64_t heap_size, struct remote_ops *ops); void palloc_heap_cleanup(struct palloc_heap *heap); size_t palloc_heap(void *heap_start); int palloc_defrag(struct palloc_heap *heap, uint64_t **objv, size_t objcnt, struct operation_context *ctx, struct pobj_defrag_result *result); /* foreach callback, terminates iteration if return value is non-zero */ typedef int (*object_callback)(const struct memory_block *m, void *arg); #if VG_MEMCHECK_ENABLED void palloc_heap_vg_open(struct palloc_heap *heap, int objects); #endif #ifdef __cplusplus } #endif #endif
3,006
25.377193
80
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/container.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2019, Intel Corporation */ /* * container.h -- internal definitions for block containers */ #ifndef LIBPMEMOBJ_CONTAINER_H #define LIBPMEMOBJ_CONTAINER_H 1 #include "memblock.h" #ifdef __cplusplus extern "C" { #endif struct block_container { const struct block_container_ops *c_ops; struct palloc_heap *heap; }; struct block_container_ops { /* inserts a new memory block into the container */ int (*insert)(struct block_container *c, const struct memory_block *m); /* removes exact match memory block */ int (*get_rm_exact)(struct block_container *c, const struct memory_block *m); /* removes and returns the best-fit memory block for size */ int (*get_rm_bestfit)(struct block_container *c, struct memory_block *m); /* checks whether the container is empty */ int (*is_empty)(struct block_container *c); /* removes all elements from the container */ void (*rm_all)(struct block_container *c); /* deletes the container */ void (*destroy)(struct block_container *c); }; #ifdef __cplusplus } #endif #endif /* LIBPMEMOBJ_CONTAINER_H */
1,125
21.979592
72
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/stats.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017-2019, Intel Corporation */ /* * stats.h -- definitions of statistics */ #ifndef LIBPMEMOBJ_STATS_H #define LIBPMEMOBJ_STATS_H 1 #include "ctl.h" #include "libpmemobj/ctl.h" #ifdef __cplusplus extern "C" { #endif struct stats_transient { uint64_t heap_run_allocated; uint64_t heap_run_active; }; struct stats_persistent { uint64_t heap_curr_allocated; }; struct stats { enum pobj_stats_enabled enabled; struct stats_transient *transient; struct stats_persistent *persistent; }; #define STATS_INC(stats, type, name, value) do {\ STATS_INC_##type(stats, name, value);\ } while (0) #define STATS_INC_transient(stats, name, value) do {\ if ((stats)->enabled == POBJ_STATS_ENABLED_TRANSIENT ||\ (stats)->enabled == POBJ_STATS_ENABLED_BOTH)\ util_fetch_and_add64((&(stats)->transient->name), (value));\ } while (0) #define STATS_INC_persistent(stats, name, value) do {\ if ((stats)->enabled == POBJ_STATS_ENABLED_PERSISTENT ||\ (stats)->enabled == POBJ_STATS_ENABLED_BOTH)\ util_fetch_and_add64((&(stats)->persistent->name), (value));\ } while (0) #define STATS_SUB(stats, type, name, value) do {\ STATS_SUB_##type(stats, name, value);\ } while (0) #define STATS_SUB_transient(stats, name, value) do {\ if ((stats)->enabled == POBJ_STATS_ENABLED_TRANSIENT ||\ (stats)->enabled == POBJ_STATS_ENABLED_BOTH)\ util_fetch_and_sub64((&(stats)->transient->name), (value));\ } while (0) #define STATS_SUB_persistent(stats, name, value) do {\ if ((stats)->enabled == POBJ_STATS_ENABLED_PERSISTENT ||\ (stats)->enabled == POBJ_STATS_ENABLED_BOTH)\ util_fetch_and_sub64((&(stats)->persistent->name), (value));\ } while (0) #define STATS_SET(stats, type, name, value) do {\ STATS_SET_##type(stats, name, value);\ } while (0) #define STATS_SET_transient(stats, name, value) do {\ if ((stats)->enabled == POBJ_STATS_ENABLED_TRANSIENT ||\ (stats)->enabled == POBJ_STATS_ENABLED_BOTH)\ util_atomic_store_explicit64((&(stats)->transient->name),\ (value), memory_order_release);\ } while (0) #define STATS_SET_persistent(stats, name, value) do {\ if ((stats)->enabled == POBJ_STATS_ENABLED_PERSISTENT ||\ (stats)->enabled == POBJ_STATS_ENABLED_BOTH)\ util_atomic_store_explicit64((&(stats)->persistent->name),\ (value), memory_order_release);\ } while (0) #define STATS_CTL_LEAF(type, name)\ {CTL_STR(name), CTL_NODE_LEAF,\ {CTL_READ_HANDLER(type##_##name), NULL, NULL},\ NULL, NULL} #define STATS_CTL_HANDLER(type, name, varname)\ static int CTL_READ_HANDLER(type##_##name)(void *ctx,\ enum ctl_query_source source, void *arg, struct ctl_indexes *indexes)\ {\ PMEMobjpool *pop = ctx;\ uint64_t *argv = arg;\ util_atomic_load_explicit64(&pop->stats->type->varname,\ argv, memory_order_acquire);\ return 0;\ } void stats_ctl_register(PMEMobjpool *pop); struct stats *stats_new(PMEMobjpool *pop); void stats_delete(PMEMobjpool *pop, struct stats *stats); #ifdef __cplusplus } #endif #endif
2,990
26.440367
71
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/container_ravl.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2018, Intel Corporation */ /* * container_ravl.h -- internal definitions for ravl-based block container */ #ifndef LIBPMEMOBJ_CONTAINER_RAVL_H #define LIBPMEMOBJ_CONTAINER_RAVL_H 1 #include "container.h" #ifdef __cplusplus extern "C" { #endif struct block_container *container_new_ravl(struct palloc_heap *heap); #ifdef __cplusplus } #endif #endif /* LIBPMEMOBJ_CONTAINER_RAVL_H */
445
17.583333
74
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/tx.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2019, Intel Corporation */ /* * tx.h -- internal definitions for transactions */ #ifndef LIBPMEMOBJ_INTERNAL_TX_H #define LIBPMEMOBJ_INTERNAL_TX_H 1 #include <stdint.h> #include "obj.h" #include "ulog.h" #ifdef __cplusplus extern "C" { #endif #define TX_DEFAULT_RANGE_CACHE_SIZE (1 << 15) #define TX_DEFAULT_RANGE_CACHE_THRESHOLD (1 << 12) #define TX_RANGE_MASK (8ULL - 1) #define TX_RANGE_MASK_LEGACY (32ULL - 1) #define TX_ALIGN_SIZE(s, amask) (((s) + (amask)) & ~(amask)) #define TX_SNAPSHOT_LOG_ENTRY_ALIGNMENT CACHELINE_SIZE #define TX_SNAPSHOT_LOG_BUFFER_OVERHEAD sizeof(struct ulog) #define TX_SNAPSHOT_LOG_ENTRY_OVERHEAD sizeof(struct ulog_entry_buf) #define TX_INTENT_LOG_BUFFER_ALIGNMENT CACHELINE_SIZE #define TX_INTENT_LOG_BUFFER_OVERHEAD sizeof(struct ulog) #define TX_INTENT_LOG_ENTRY_OVERHEAD sizeof(struct ulog_entry_val) struct tx_parameters { size_t cache_size; }; /* * Returns the current transaction's pool handle, NULL if not within * a transaction. */ PMEMobjpool *tx_get_pop(void); void tx_ctl_register(PMEMobjpool *pop); struct tx_parameters *tx_params_new(void); void tx_params_delete(struct tx_parameters *tx_params); #ifdef __cplusplus } #endif #endif
1,258
22.314815
68
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/memblock.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2020, Intel Corporation */ /* * memblock.h -- internal definitions for memory block */ #ifndef LIBPMEMOBJ_MEMBLOCK_H #define LIBPMEMOBJ_MEMBLOCK_H 1 #include <stddef.h> #include <stdint.h> #include "os_thread.h" #include "heap_layout.h" #include "memops.h" #include "palloc.h" #ifdef __cplusplus extern "C" { #endif #define MEMORY_BLOCK_NONE \ (struct memory_block)\ {0, 0, 0, 0, NULL, NULL, MAX_HEADER_TYPES, MAX_MEMORY_BLOCK, NULL} #define MEMORY_BLOCK_IS_NONE(_m)\ ((_m).heap == NULL) #define MEMORY_BLOCK_EQUALS(lhs, rhs)\ ((lhs).zone_id == (rhs).zone_id && (lhs).chunk_id == (rhs).chunk_id &&\ (lhs).block_off == (rhs).block_off && (lhs).heap == (rhs).heap) enum memory_block_type { /* * Huge memory blocks are directly backed by memory chunks. A single * huge block can consist of several chunks. * The persistent representation of huge memory blocks can be thought * of as a doubly linked list with variable length elements. * That list is stored in the chunk headers array where one element * directly corresponds to one chunk. * * U - used, F - free, R - footer, . - empty * |U| represents a used chunk with a size index of 1, with type * information (CHUNK_TYPE_USED) stored in the corresponding header * array element - chunk_headers[chunk_id]. * * |F...R| represents a free chunk with size index of 5. The empty * chunk headers have undefined values and shouldn't be used. All * chunks with size larger than 1 must have a footer in the last * corresponding header array - chunk_headers[chunk_id - size_idx - 1]. * * The above representation of chunks will be used to describe the * way fail-safety is achieved during heap operations. * * Allocation of huge memory block with size index 5: * Initial heap state: |U| <> |F..R| <> |U| <> |F......R| * * The only block that matches that size is at very end of the chunks * list: |F......R| * * As the request was for memory block of size 5, and this ones size is * 7 there's a need to first split the chunk in two. * 1) The last chunk header of the new allocation is marked as footer * and the block after that one is marked as free: |F...RF.R| * This is allowed and has no impact on the heap because this * modification is into chunk header that is otherwise unused, in * other words the linked list didn't change. * * 2) The size index of the first header is changed from previous value * of 7 to 5: |F...R||F.R| * This is a single fail-safe atomic operation and this is the * first change that is noticeable by the heap operations. * A single linked list element is split into two new ones. * * 3) The allocation process either uses redo log or changes directly * the chunk header type from free to used: |U...R| <> |F.R| * * In a similar fashion the reverse operation, free, is performed: * Initial heap state: |U| <> |F..R| <> |F| <> |U...R| <> |F.R| * * This is the heap after the previous example with the single chunk * in between changed from used to free. * * 1) Determine the neighbors of the memory block which is being * freed. * * 2) Update the footer (if needed) information of the last chunk which * is the memory block being freed or it's neighbor to the right. * |F| <> |U...R| <> |F.R << this one| * * 3) Update the size index and type of the left-most chunk header. * And so this: |F << this one| <> |U...R| <> |F.R| * becomes this: |F.......R| * The entire chunk header can be updated in a single fail-safe * atomic operation because it's size is only 64 bytes. */ MEMORY_BLOCK_HUGE, /* * Run memory blocks are chunks with CHUNK_TYPE_RUN and size index of 1. * The entire chunk is subdivided into smaller blocks and has an * additional metadata attached in the form of a bitmap - each bit * corresponds to a single block. * In this case there's no need to perform any coalescing or splitting * on the persistent metadata. * The bitmap is stored on a variable number of 64 bit values and * because of the requirement of allocation fail-safe atomicity the * maximum size index of a memory block from a run is 64 - since that's * the limit of atomic write guarantee. * * The allocation/deallocation process is a single 8 byte write that * sets/clears the corresponding bits. Depending on the user choice * it can either be made atomically or using redo-log when grouped with * other operations. * It's also important to note that in a case of realloc it might so * happen that a single 8 byte bitmap value has its bits both set and * cleared - that's why the run memory block metadata changes operate * on AND'ing or OR'ing a bitmask instead of directly setting the value. */ MEMORY_BLOCK_RUN, MAX_MEMORY_BLOCK }; enum memblock_state { MEMBLOCK_STATE_UNKNOWN, MEMBLOCK_ALLOCATED, MEMBLOCK_FREE, MAX_MEMBLOCK_STATE, }; /* runtime bitmap information for a run */ struct run_bitmap { unsigned nvalues; /* number of 8 byte values - size of values array */ unsigned nbits; /* number of valid bits */ size_t size; /* total size of the bitmap in bytes */ uint64_t *values; /* pointer to the bitmap's values array */ }; /* runtime information necessary to create a run */ struct run_descriptor { uint16_t flags; /* chunk flags for the run */ size_t unit_size; /* the size of a single unit in a run */ uint32_t size_idx; /* size index of a single run instance */ size_t alignment; /* required alignment of objects */ unsigned nallocs; /* number of allocs per run */ struct run_bitmap bitmap; }; struct memory_block_ops { /* returns memory block size */ size_t (*block_size)(const struct memory_block *m); /* prepares header modification operation */ void (*prep_hdr)(const struct memory_block *m, enum memblock_state dest_state, struct operation_context *ctx); /* returns lock associated with memory block */ os_mutex_t *(*get_lock)(const struct memory_block *m); /* returns whether a block is allocated or not */ enum memblock_state (*get_state)(const struct memory_block *m); /* returns pointer to the data of a block */ void *(*get_user_data)(const struct memory_block *m); /* * Returns the size of a memory block without overhead. * This is the size of a data block that can be used. */ size_t (*get_user_size)(const struct memory_block *m); /* returns pointer to the beginning of data of a run block */ void *(*get_real_data)(const struct memory_block *m); /* returns the size of a memory block, including headers */ size_t (*get_real_size)(const struct memory_block *m); /* writes a header of an allocation */ void (*write_header)(const struct memory_block *m, uint64_t extra_field, uint16_t flags); void (*invalidate)(const struct memory_block *m); /* * Checks the header type of a chunk matches the expected type and * modifies it if necessary. This is fail-safe atomic. */ void (*ensure_header_type)(const struct memory_block *m, enum header_type t); /* * Reinitializes a block after a heap restart. * This is called for EVERY allocation, but *only* under Valgrind. */ void (*reinit_header)(const struct memory_block *m); /* returns the extra field of an allocation */ uint64_t (*get_extra)(const struct memory_block *m); /* returns the flags of an allocation */ uint16_t (*get_flags)(const struct memory_block *m); /* initializes memblock in valgrind */ void (*vg_init)(const struct memory_block *m, int objects, object_callback cb, void *arg); /* iterates over every free block */ int (*iterate_free)(const struct memory_block *m, object_callback cb, void *arg); /* iterates over every used block */ int (*iterate_used)(const struct memory_block *m, object_callback cb, void *arg); /* calculates number of free units, valid only for runs */ void (*calc_free)(const struct memory_block *m, uint32_t *free_space, uint32_t *max_free_block); /* this is called exactly once for every existing chunk */ void (*reinit_chunk)(const struct memory_block *m); /* * Initializes bitmap data for a run. * Do *not* use this function unless absolutely necessary, it breaks * the abstraction layer by exposing implementation details. */ void (*get_bitmap)(const struct memory_block *m, struct run_bitmap *b); /* calculates the ratio between occupied and unoccupied space */ unsigned (*fill_pct)(const struct memory_block *m); }; struct memory_block { uint32_t chunk_id; /* index of the memory block in its zone */ uint32_t zone_id; /* index of this block zone in the heap */ /* * Size index of the memory block represented in either multiple of * CHUNKSIZE in the case of a huge chunk or in multiple of a run * block size. */ uint32_t size_idx; /* * Used only for run chunks, must be zeroed for huge. * Number of preceding blocks in the chunk. In other words, the * position of this memory block in run bitmap. */ uint32_t block_off; /* * The variables below are associated with the memory block and are * stored here for convenience. Those fields are filled by either the * memblock_from_offset or memblock_rebuild_state, and they should not * be modified manually. */ const struct memory_block_ops *m_ops; struct palloc_heap *heap; enum header_type header_type; enum memory_block_type type; struct run_bitmap *cached_bitmap; }; /* * This is a representation of a run memory block that is active in a bucket or * is on a pending list in the recycler. * This structure should never be passed around by value because the address of * the nresv variable can be in reservations made through palloc_reserve(). Only * if the number of reservations equals 0 the structure can be moved/freed. */ struct memory_block_reserved { struct memory_block m; struct bucket *bucket; /* * Number of reservations made from this run, the pointer to this value * is stored in a user facing pobj_action structure. Decremented once * the reservation is published or canceled. */ int nresv; }; struct memory_block memblock_from_offset(struct palloc_heap *heap, uint64_t off); struct memory_block memblock_from_offset_opt(struct palloc_heap *heap, uint64_t off, int size); void memblock_rebuild_state(struct palloc_heap *heap, struct memory_block *m); struct memory_block memblock_huge_init(struct palloc_heap *heap, uint32_t chunk_id, uint32_t zone_id, uint32_t size_idx); struct memory_block memblock_run_init(struct palloc_heap *heap, uint32_t chunk_id, uint32_t zone_id, struct run_descriptor *rdsc); void memblock_run_bitmap(uint32_t *size_idx, uint16_t flags, uint64_t unit_size, uint64_t alignment, void *content, struct run_bitmap *b); #ifdef __cplusplus } #endif #endif
10,750
34.019544
80
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/critnib.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2018, Intel Corporation */ /* * critnib.h -- internal definitions for critnib tree */ #ifndef LIBPMEMOBJ_CRITNIB_H #define LIBPMEMOBJ_CRITNIB_H 1 #include <stdint.h> #ifdef __cplusplus extern "C" { #endif struct critnib; struct critnib *critnib_new(void); void critnib_delete(struct critnib *c); int critnib_insert(struct critnib *c, uint64_t key, void *value); void *critnib_remove(struct critnib *c, uint64_t key); void *critnib_get(struct critnib *c, uint64_t key); void *critnib_find_le(struct critnib *c, uint64_t key); #ifdef __cplusplus } #endif #endif
625
18.5625
65
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/pmemops.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2018, Intel Corporation */ #ifndef LIBPMEMOBJ_PMEMOPS_H #define LIBPMEMOBJ_PMEMOPS_H 1 #include <stddef.h> #include <stdint.h> #include "util.h" #ifdef __cplusplus extern "C" { #endif typedef int (*persist_fn)(void *base, const void *, size_t, unsigned); typedef int (*flush_fn)(void *base, const void *, size_t, unsigned); typedef void (*drain_fn)(void *base); typedef void *(*memcpy_fn)(void *base, void *dest, const void *src, size_t len, unsigned flags); typedef void *(*memmove_fn)(void *base, void *dest, const void *src, size_t len, unsigned flags); typedef void *(*memset_fn)(void *base, void *dest, int c, size_t len, unsigned flags); typedef int (*remote_read_fn)(void *ctx, uintptr_t base, void *dest, void *addr, size_t length); struct pmem_ops { /* for 'master' replica: with or without data replication */ persist_fn persist; /* persist function */ flush_fn flush; /* flush function */ drain_fn drain; /* drain function */ memcpy_fn memcpy; /* persistent memcpy function */ memmove_fn memmove; /* persistent memmove function */ memset_fn memset; /* persistent memset function */ void *base; //char a; //temp var end struct remote_ops { remote_read_fn read; void *ctx; uintptr_t base; } remote; void *device; uint16_t objid; }; static force_inline int pmemops_xpersist(const struct pmem_ops *p_ops, const void *d, size_t s, unsigned flags) { return p_ops->persist(p_ops->base, d, s, flags); } static force_inline void pmemops_persist(const struct pmem_ops *p_ops, const void *d, size_t s) { (void) pmemops_xpersist(p_ops, d, s, 0); } static force_inline int pmemops_xflush(const struct pmem_ops *p_ops, const void *d, size_t s, unsigned flags) { return p_ops->flush(p_ops->base, d, s, flags); } static force_inline void pmemops_flush(const struct pmem_ops *p_ops, const void *d, size_t s) { (void) pmemops_xflush(p_ops, d, s, 0); } static force_inline void pmemops_drain(const struct pmem_ops *p_ops) { p_ops->drain(p_ops->base); } static force_inline void * pmemops_memcpy(const struct pmem_ops *p_ops, void *dest, const void *src, size_t len, unsigned flags) { return p_ops->memcpy(p_ops->base, dest, src, len, flags); } static force_inline void * pmemops_memmove(const struct pmem_ops *p_ops, void *dest, const void *src, size_t len, unsigned flags) { return p_ops->memmove(p_ops->base, dest, src, len, flags); } static force_inline void * pmemops_memset(const struct pmem_ops *p_ops, void *dest, int c, size_t len, unsigned flags) { return p_ops->memset(p_ops->base, dest, c, len, flags); } #ifdef __cplusplus } #endif #endif
2,672
22.866071
80
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/sync.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2018, Intel Corporation */ /* * sync.h -- internal to obj synchronization API */ #ifndef LIBPMEMOBJ_SYNC_H #define LIBPMEMOBJ_SYNC_H 1 #include <errno.h> #include <stdint.h> #include "libpmemobj.h" #include "out.h" #include "os_thread.h" #ifdef __cplusplus extern "C" { #endif /* * internal definitions of PMEM-locks */ typedef union padded_pmemmutex { char padding[_POBJ_CL_SIZE]; struct { uint64_t runid; union { os_mutex_t mutex; struct { void *bsd_mutex_p; union padded_pmemmutex *next; } bsd_u; } mutex_u; } pmemmutex; } PMEMmutex_internal; #define PMEMmutex_lock pmemmutex.mutex_u.mutex #define PMEMmutex_bsd_mutex_p pmemmutex.mutex_u.bsd_u.bsd_mutex_p #define PMEMmutex_next pmemmutex.mutex_u.bsd_u.next typedef union padded_pmemrwlock { char padding[_POBJ_CL_SIZE]; struct { uint64_t runid; union { os_rwlock_t rwlock; struct { void *bsd_rwlock_p; union padded_pmemrwlock *next; } bsd_u; } rwlock_u; } pmemrwlock; } PMEMrwlock_internal; #define PMEMrwlock_lock pmemrwlock.rwlock_u.rwlock #define PMEMrwlock_bsd_rwlock_p pmemrwlock.rwlock_u.bsd_u.bsd_rwlock_p #define PMEMrwlock_next pmemrwlock.rwlock_u.bsd_u.next typedef union padded_pmemcond { char padding[_POBJ_CL_SIZE]; struct { uint64_t runid; union { os_cond_t cond; struct { void *bsd_cond_p; union padded_pmemcond *next; } bsd_u; } cond_u; } pmemcond; } PMEMcond_internal; #define PMEMcond_cond pmemcond.cond_u.cond #define PMEMcond_bsd_cond_p pmemcond.cond_u.bsd_u.bsd_cond_p #define PMEMcond_next pmemcond.cond_u.bsd_u.next /* * pmemobj_mutex_lock_nofail -- pmemobj_mutex_lock variant that never * fails from caller perspective. If pmemobj_mutex_lock failed, this function * aborts the program. */ static inline void pmemobj_mutex_lock_nofail(PMEMobjpool *pop, PMEMmutex *mutexp) { int ret = pmemobj_mutex_lock(pop, mutexp); if (ret) { errno = ret; FATAL("!pmemobj_mutex_lock"); } } /* * pmemobj_mutex_unlock_nofail -- pmemobj_mutex_unlock variant that never * fails from caller perspective. If pmemobj_mutex_unlock failed, this function * aborts the program. */ static inline void pmemobj_mutex_unlock_nofail(PMEMobjpool *pop, PMEMmutex *mutexp) { int ret = pmemobj_mutex_unlock(pop, mutexp); if (ret) { errno = ret; FATAL("!pmemobj_mutex_unlock"); } } int pmemobj_mutex_assert_locked(PMEMobjpool *pop, PMEMmutex *mutexp); #ifdef __cplusplus } #endif #endif
2,504
21.168142
79
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/lane.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2019, Intel Corporation */ /* * lane.h -- internal definitions for lanes */ #ifndef LIBPMEMOBJ_LANE_H #define LIBPMEMOBJ_LANE_H 1 #include <stdint.h> #include "ulog.h" #include "libpmemobj.h" #ifdef __cplusplus extern "C" { #endif /* * Distance between lanes used by threads required to prevent threads from * false sharing part of lanes array. Used if properly spread lanes are * available. Otherwise less spread out lanes would be used. */ #define LANE_JUMP (64 / sizeof(uint64_t)) /* * Number of times the algorithm will try to reacquire the primary lane for the * thread. If this threshold is exceeded, a new primary lane is selected for the * thread. */ #define LANE_PRIMARY_ATTEMPTS 128 #define RLANE_DEFAULT 0 #define LANE_TOTAL_SIZE 3072 /* 3 * 1024 (sum of 3 old lane sections) */ /* * We have 3 kilobytes to distribute. * The smallest capacity is needed for the internal redo log for which we can * accurately calculate the maximum number of occupied space: 48 bytes, * 3 times sizeof(struct ulog_entry_val). One for bitmap OR, second for bitmap * AND, third for modification of the destination pointer. For future needs, * this has been bumped up to 12 ulog entries. * * The remaining part has to be split between transactional redo and undo logs, * and since by far the most space consuming operations are transactional * snapshots, most of the space, 2 kilobytes, is assigned to the undo log. * After that, the remainder, 640 bytes, or 40 ulog entries, is left for the * transactional redo logs. * Thanks to this distribution, all small and medium transactions should be * entirely performed without allocating any additional metadata. * * These values must be cacheline size aligned to be used for ulogs. Therefore * they are parametrized for the size of the struct ulog changes between * platforms. */ #define LANE_UNDO_SIZE (LANE_TOTAL_SIZE \ - LANE_REDO_EXTERNAL_SIZE \ - LANE_REDO_INTERNAL_SIZE \ - 3 * sizeof(struct ulog)) /* 2048 for 64B ulog */ #define LANE_REDO_EXTERNAL_SIZE ALIGN_UP(704 - sizeof(struct ulog), \ CACHELINE_SIZE) /* 640 for 64B ulog */ #define LANE_REDO_INTERNAL_SIZE ALIGN_UP(256 - sizeof(struct ulog), \ CACHELINE_SIZE) /* 192 for 64B ulog */ struct lane_layout { /* * Redo log for self-contained and 'one-shot' allocator operations. * Cannot be extended. */ struct ULOG(LANE_REDO_INTERNAL_SIZE) internal; /* * Redo log for large operations/transactions. * Can be extended by the use of internal ulog. */ struct ULOG(LANE_REDO_EXTERNAL_SIZE) external; /* * Undo log for snapshots done in a transaction. * Can be extended/shrunk by the use of internal ulog. */ struct ULOG(LANE_UNDO_SIZE) undo; }; struct lane { struct lane_layout *layout; /* pointer to persistent layout */ struct operation_context *internal; /* context for internal ulog */ struct operation_context *external; /* context for external ulog */ struct operation_context *undo; /* context for undo ulog */ }; struct lane_descriptor { /* * Number of lanes available at runtime must be <= total number of lanes * available in the pool. Number of lanes can be limited by shortage of * other resources e.g. available RNIC's submission queue sizes. */ unsigned runtime_nlanes; unsigned next_lane_idx; uint64_t *lane_locks; struct lane *lane; }; typedef int (*section_layout_op)(PMEMobjpool *pop, void *data, unsigned length); typedef void *(*section_constr)(PMEMobjpool *pop, void *data); typedef void (*section_destr)(PMEMobjpool *pop, void *rt); typedef int (*section_global_op)(PMEMobjpool *pop); struct section_operations { section_constr construct_rt; section_destr destroy_rt; section_layout_op check; section_layout_op recover; section_global_op boot; section_global_op cleanup; }; struct lane_info { uint64_t pop_uuid_lo; uint64_t lane_idx; unsigned long nest_count; /* * The index of the primary lane for the thread. A thread will always * try to acquire the primary lane first, and only if that fails it will * look for a different available lane. */ uint64_t primary; int primary_attempts; struct lane_info *prev, *next; }; void lane_info_boot(void); void lane_info_destroy(void); void lane_init_data(PMEMobjpool *pop); int lane_boot(PMEMobjpool *pop); void lane_cleanup(PMEMobjpool *pop); int lane_recover_and_section_boot(PMEMobjpool *pop); int lane_section_cleanup(PMEMobjpool *pop); int lane_check(PMEMobjpool *pop); unsigned lane_hold(PMEMobjpool *pop, struct lane **lane); void lane_release(PMEMobjpool *pop); #ifdef __cplusplus } #endif #endif
4,652
30.02
80
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/bucket.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2019, Intel Corporation */ /* * bucket.h -- internal definitions for bucket */ #ifndef LIBPMEMOBJ_BUCKET_H #define LIBPMEMOBJ_BUCKET_H 1 #include <stddef.h> #include <stdint.h> #include "container.h" #include "memblock.h" #include "os_thread.h" #ifdef __cplusplus extern "C" { #endif #define CALC_SIZE_IDX(_unit_size, _size)\ ((_size) == 0 ? 0 : (uint32_t)((((_size) - 1) / (_unit_size)) + 1)) struct bucket { os_mutex_t lock; struct alloc_class *aclass; struct block_container *container; const struct block_container_ops *c_ops; struct memory_block_reserved *active_memory_block; int is_active; }; struct bucket *bucket_new(struct block_container *c, struct alloc_class *aclass); int *bucket_current_resvp(struct bucket *b); int bucket_insert_block(struct bucket *b, const struct memory_block *m); void bucket_delete(struct bucket *b); #ifdef __cplusplus } #endif #endif
957
17.784314
72
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/libpmemobj/ulog.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2020, Intel Corporation */ /* * ulog.h -- unified log public interface */ #ifndef LIBPMEMOBJ_ULOG_H #define LIBPMEMOBJ_ULOG_H 1 #include <stddef.h> #include <stdint.h> #include <time.h> #include "vec.h" #include "pmemops.h" #include<x86intrin.h> ////cmd write optimization /* struct ulog_cmd_packet{ uint32_t ulog_offset : 32; uint32_t base_offset : 32; uint32_t src : 32; uint32_t size : 32; }; */ struct ulog_entry_base { uint64_t offset; /* offset with operation type flag */ }; /* * ulog_entry_val -- log entry */ struct ulog_entry_val { struct ulog_entry_base base; uint64_t value; /* value to be applied */ }; /* * ulog_entry_buf - ulog buffer entry */ struct ulog_entry_buf { struct ulog_entry_base base; /* offset with operation type flag */ uint64_t checksum; /* checksum of the entire log entry */ uint64_t size; /* size of the buffer to be modified */ uint8_t data[]; /* content to fill in */ }; #define ULOG_UNUSED ((CACHELINE_SIZE - 40) / 8) /* * This structure *must* be located at a cacheline boundary. To achieve this, * the next field is always allocated with extra padding, and then the offset * is additionally aligned. */ #define ULOG(capacity_bytes) {\ /* 64 bytes of metadata */\ uint64_t checksum; /* checksum of ulog header and its entries */\ uint64_t next; /* offset of ulog extension */\ uint64_t capacity; /* capacity of this ulog in bytes */\ uint64_t gen_num; /* generation counter */\ uint64_t flags; /* ulog flags */\ uint64_t unused[ULOG_UNUSED]; /* must be 0 */\ uint8_t data[capacity_bytes]; /* N bytes of data */\ }\ #define SIZEOF_ULOG(base_capacity)\ (sizeof(struct ulog) + base_capacity) /* * Ulog buffer allocated by the user must be marked by this flag. * It is important to not free it at the end: * what user has allocated - user should free himself. */ #define ULOG_USER_OWNED (1U << 0) /* use this for allocations of aligned ulog extensions */ #define SIZEOF_ALIGNED_ULOG(base_capacity)\ ALIGN_UP(SIZEOF_ULOG(base_capacity + (2 * CACHELINE_SIZE)), CACHELINE_SIZE) struct ulog ULOG(0); VEC(ulog_next, uint64_t); typedef uint64_t ulog_operation_type; #define ULOG_OPERATION_SET (0b000ULL << 61ULL) #define ULOG_OPERATION_AND (0b001ULL << 61ULL) #define ULOG_OPERATION_OR (0b010ULL << 61ULL) #define ULOG_OPERATION_BUF_SET (0b101ULL << 61ULL) #define ULOG_OPERATION_BUF_CPY (0b110ULL << 61ULL) #define ULOG_BIT_OPERATIONS (ULOG_OPERATION_AND | ULOG_OPERATION_OR) /* immediately frees all associated ulog structures */ #define ULOG_FREE_AFTER_FIRST (1U << 0) /* increments gen_num of the first, preallocated, ulog */ #define ULOG_INC_FIRST_GEN_NUM (1U << 1) /* informs if there was any buffer allocated by user in the tx */ #define ULOG_ANY_USER_BUFFER (1U << 2) typedef int (*ulog_check_offset_fn)(void *ctx, uint64_t offset); typedef int (*ulog_extend_fn)(void *, uint64_t *, uint64_t); typedef int (*ulog_entry_cb)(struct ulog_entry_base *e, void *arg, const struct pmem_ops *p_ops); typedef int (*ulog_entry_cb_ndp)(struct ulog_entry_base *e, struct ulog_entry_base *f, void *arg, const struct pmem_ops *p_ops); typedef void (*ulog_free_fn)(void *base, uint64_t *next); typedef int (*ulog_rm_user_buffer_fn)(void *, void *addr); struct ulog *ulog_next(struct ulog *ulog, const struct pmem_ops *p_ops); void ulog_construct(uint64_t offset, size_t capacity, uint64_t gen_num, int flush, uint64_t flags, const struct pmem_ops *p_ops); size_t ulog_capacity(struct ulog *ulog, size_t ulog_base_bytes, const struct pmem_ops *p_ops); void ulog_rebuild_next_vec(struct ulog *ulog, struct ulog_next *next, const struct pmem_ops *p_ops); int ulog_foreach_entry(struct ulog *ulog, ulog_entry_cb cb, void *arg, const struct pmem_ops *ops, struct ulog *ulognvm); int ulog_foreach_entry_ndp(struct ulog *ulogdram, struct ulog *ulognvm, ulog_entry_cb_ndp cb, void *arg, const struct pmem_ops *ops); int ulog_reserve(struct ulog *ulog, size_t ulog_base_nbytes, size_t gen_num, int auto_reserve, size_t *new_capacity_bytes, ulog_extend_fn extend, struct ulog_next *next, const struct pmem_ops *p_ops); void ulog_store(struct ulog *dest, struct ulog *src, size_t nbytes, size_t ulog_base_nbytes, size_t ulog_total_capacity, struct ulog_next *next, const struct pmem_ops *p_ops); int ulog_free_next(struct ulog *u, const struct pmem_ops *p_ops, ulog_free_fn ulog_free, ulog_rm_user_buffer_fn user_buff_remove, uint64_t flags); void ulog_clobber(struct ulog *dest, struct ulog_next *next, const struct pmem_ops *p_ops); int ulog_clobber_data(struct ulog *dest, size_t nbytes, size_t ulog_base_nbytes, struct ulog_next *next, ulog_free_fn ulog_free, ulog_rm_user_buffer_fn user_buff_remove, const struct pmem_ops *p_ops, unsigned flags); void ulog_clobber_entry(const struct ulog_entry_base *e, const struct pmem_ops *p_ops); void ulog_process(struct ulog *ulog, ulog_check_offset_fn check, const struct pmem_ops *p_ops); void ulog_process_ndp(struct ulog *ulognvm, struct ulog *ulogdeam, ulog_check_offset_fn check, const struct pmem_ops *p_ops); size_t ulog_base_nbytes(struct ulog *ulog); int ulog_recovery_needed(struct ulog *ulog, int verify_checksum); struct ulog *ulog_by_offset(size_t offset, const struct pmem_ops *p_ops); uint64_t ulog_entry_offset(const struct ulog_entry_base *entry); ulog_operation_type ulog_entry_type( const struct ulog_entry_base *entry); struct ulog_entry_val *ulog_entry_val_create(struct ulog *ulog, size_t offset, uint64_t *dest, uint64_t value, ulog_operation_type type, const struct pmem_ops *p_ops); #ifdef USE_NDP_CLOBBER struct ulog_entry_buf * ulog_entry_buf_create(struct ulog *ulog, size_t offset, uint64_t gen_num, uint64_t *dest, const void *src, uint64_t size, ulog_operation_type type, const struct pmem_ops *p_ops, int clear_next_header); #else struct ulog_entry_buf * ulog_entry_buf_create(struct ulog *ulog, size_t offset, uint64_t gen_num, uint64_t *dest, const void *src, uint64_t size, ulog_operation_type type, const struct pmem_ops *p_ops); #endif void ulog_entry_apply(const struct ulog_entry_base *e, int persist, const struct pmem_ops *p_ops); void ulog_entry_apply_ndp(const struct ulog_entry_base *e, const struct ulog_entry_base *f, int persist, const struct pmem_ops *p_ops); size_t ulog_entry_size(const struct ulog_entry_base *entry); void ulog_recover(struct ulog *ulog, ulog_check_offset_fn check, const struct pmem_ops *p_ops); int ulog_check(struct ulog *ulog, ulog_check_offset_fn check, const struct pmem_ops *p_ops); #endif
6,600
32.170854
104
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/common_badblock.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2018-2020, Intel Corporation # # src/test/common_badblock.sh -- commons for the following tests: # - util_badblock # - pmempool_create # - pmempool_info # LOG=out${UNITTEST_NUM}.log UNITTEST_DIRNAME=$(echo $UNITTEST_NAME | cut -d'/' -f1) COMMAND_MOUNTED_DIRS="\ mount | grep -e $UNITTEST_DIRNAME | cut -d' ' -f1 | xargs && true" COMMAND_NDCTL_NFIT_TEST_INIT="\ sudo modprobe nfit_test &>>$PREP_LOG_FILE && \ sudo ndctl disable-region all &>>$PREP_LOG_FILE && \ sudo ndctl zero-labels all &>>$PREP_LOG_FILE && \ sudo ndctl enable-region all &>>$PREP_LOG_FILE" COMMAND_NDCTL_NFIT_TEST_FINI="\ sudo ndctl disable-region all &>>$PREP_LOG_FILE && \ sudo modprobe -r nfit_test &>>$PREP_LOG_FILE" # # badblock_test_init -- initialize badblock test based on underlying hardware # # Input arguments: # 1) device type (dax_device|block_device) # 2) mount directory (in case of block device type) # function badblock_test_init() { case "$1" in dax_device|block_device) ;; *) usage "bad device type: $1" ;; esac DEVTYPE=$1 if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then ndctl_nfit_test_init fi if [ "$DEVTYPE" == "dax_device" ]; then DEVICE=$(badblock_test_get_dax_device) elif [ "$DEVTYPE" == "block_device" ]; then DEVICE=$(badblock_test_get_block_device) prepare_mount_dir $DEVICE $2 fi NAMESPACE=$(ndctl_get_namespace_of_device $DEVICE) FULLDEV="/dev/$DEVICE" # current unit tests support only block sizes less or equal 4096 bytes require_max_block_size $FULLDEV 4096 } # # badblock_test_init_node -- initialize badblock test based on underlying # hardware on a remote node # # Input arguments: # 1) remote node number # 2) device type (dax_device|block_device) # 3) for block device: mount directory # for dax device on real pmem: dax device index on a given node # function badblock_test_init_node() { case "$2" in dax_device|block_device) ;; *) usage "bad device type: $2" ;; esac DEVTYPE=$2 if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then ndctl_nfit_test_init_node $1 fi if [ "$DEVTYPE" == "dax_device" ]; then DEVICE=$(badblock_test_get_dax_device_node $1 $3) elif [ "$DEVTYPE" == "block_device" ]; then DEVICE=$(badblock_test_get_block_device_node $1) prepare_mount_dir_node $1 $DEVICE $3 fi NAMESPACE=$(ndctl_get_namespace_of_device_node $1 $DEVICE) FULLDEV="/dev/$DEVICE" } # # badblock_test_get_dax_device -- get name of the dax device # function badblock_test_get_dax_device() { DEVICE="" if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then DEVICE=$(ndctl_nfit_test_get_dax_device) elif [ "$BADBLOCK_TEST_TYPE" == "real_pmem" ]; then DEVICE=$(real_pmem_get_dax_device) fi echo $DEVICE } # # badblock_test_get_dax_device_node -- get name of the dax device on a given # remote node # Input arguments: # 1) remote node number # 2) For real pmem: device dax index on a given node # function badblock_test_get_dax_device_node() { DEVICE="" if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then DEVICE=$(ndctl_nfit_test_get_dax_device_node $1) elif [ "$BADBLOCK_TEST_TYPE" == "real_pmem" ]; then DEVICE=$(real_pmem_get_dax_device_node $1 $2) fi echo $DEVICE } # # badblock_test_get_block_device -- get name of the block device # function badblock_test_get_block_device() { DEVICE="" if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then DEVICE=$(ndctl_nfit_test_get_block_device) elif [ "$BADBLOCK_TEST_TYPE" == "real_pmem" ]; then DEVICE=$(real_pmem_get_block_device) fi echo "$DEVICE" } # # badblock_test_get_block_device_node -- get name of the block device on a given # remote node # function badblock_test_get_block_device_node() { DEVICE="" if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then DEVICE=$(ndctl_nfit_test_get_block_device_node $1) elif [ "$BADBLOCK_TEST_TYPE" == "real_pmem" ]; then DEVICE=$(real_pmem_get_block_device_node $1) fi echo "$DEVICE" } # # prepare_mount_dir -- prepare the mount directory for provided device # # Input arguments: # 1) device name # 2) mount directory # function prepare_mount_dir() { if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then local FULLDEV="/dev/$1" ndctl_nfit_test_mount_pmem $FULLDEV $2 elif [ "$BADBLOCK_TEST_TYPE" == "real_pmem" ]; then if [ ! -d $2 ]; then mkdir -p $2 fi fi } # # prepare_mount_dir_node -- prepare the mount directory for provided device # on a given remote node # # Input arguments: # 1) remote node number # 2) device name # 3) mount directory # function prepare_mount_dir_node() { if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then local FULLDEV="/dev/$2" ndctl_nfit_test_mount_pmem_node $1 $FULLDEV $3 elif [ "$BADBLOCK_TEST_TYPE" == "real_pmem" ]; then if [ ! -d $3 ]; then run_on_node $1 "mkdir -p $3" fi fi } # # real_pmem_get_dax_device -- get real pmem dax device name # function real_pmem_get_dax_device() { local FULLDEV=${DEVICE_DAX_PATH[0]} DEVICE=${FULLDEV##*/} echo $DEVICE } # # real_pmem_get_dax_device_node -- get real pmem dax device name on a given # remote node # # Input arguments: # 1) remote node number # 2) device dax index number # function real_pmem_get_dax_device_node() { local node=$1 local devdax_index=$2 local device_dax_path=(${NODE_DEVICE_DAX_PATH[$node]}) local FULLDEV=${device_dax_path[$devdax_index]} DEVICE=${FULLDEV##*/} echo $DEVICE } # # real_pmem_get_block_device -- get real pmem block device name # function real_pmem_get_block_device() { local FULL_DEV=$(mount | grep $PMEM_FS_DIR | cut -f 1 -d" ") DEVICE=${FULL_DEV##*/} echo $DEVICE } # # real_pmem_get_block_device_node -- get real pmem block device name on a given # remote node # function real_pmem_get_block_device_node() { local FULL_DEV=$(expect_normal_exit run_on_node $1 mount | grep $PMEM_FS_DIR | cut -f 1 -d" ") DEVICE=${FULL_DEV##*/} echo $DEVICE } # # ndctl_nfit_test_init -- reset all regions and reload the nfit_test module # function ndctl_nfit_test_init() { sudo ndctl disable-region all &>>$PREP_LOG_FILE if ! sudo modprobe -r nfit_test &>>$PREP_LOG_FILE; then MOUNTED_DIRS="$(eval $COMMAND_MOUNTED_DIRS)" [ "$MOUNTED_DIRS" ] && sudo umount $MOUNTED_DIRS sudo ndctl disable-region all &>>$PREP_LOG_FILE sudo modprobe -r nfit_test fi expect_normal_exit $COMMAND_NDCTL_NFIT_TEST_INIT } # # ndctl_nfit_test_init_node -- reset all regions and reload the nfit_test # module on a remote node # function ndctl_nfit_test_init_node() { run_on_node $1 "sudo ndctl disable-region all &>>$PREP_LOG_FILE" if ! run_on_node $1 "sudo modprobe -r nfit_test &>>$PREP_LOG_FILE"; then MOUNTED_DIRS="$(run_on_node $1 $COMMAND_MOUNTED_DIRS)" run_on_node $1 "\ [ \"$MOUNTED_DIRS\" ] && sudo umount $MOUNTED_DIRS; \ sudo ndctl disable-region all &>>$PREP_LOG_FILE; \ sudo modprobe -r nfit_test" fi expect_normal_exit run_on_node $1 "$COMMAND_NDCTL_NFIT_TEST_INIT" } # # badblock_test_fini -- clean badblock test based on underlying hardware # # Input arguments: # 1) pmem mount directory to be umounted (optional) # function badblock_test_fini() { if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then ndctl_nfit_test_fini $1 fi } # # badblock_test_fini_node() -- clean badblock test based on underlying hardware # on a given remote node # # Input arguments: # 1) node number # 2) pmem mount directory to be umounted (optional) # function badblock_test_fini_node() { if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then ndctl_nfit_test_fini_node $1 $2 fi } # # ndctl_nfit_test_fini -- clean badblock test ran on nfit_test based on underlying hardware # function ndctl_nfit_test_fini() { MOUNT_DIR=$1 [ $MOUNT_DIR ] && sudo umount $MOUNT_DIR &>> $PREP_LOG_FILE expect_normal_exit $COMMAND_NDCTL_NFIT_TEST_FINI } # # ndctl_nfit_test_fini_node -- disable all regions, remove the nfit_test module # and (optionally) umount the pmem block device on a remote node # # Input arguments: # 1) node number # 2) pmem mount directory to be umounted # function ndctl_nfit_test_fini_node() { MOUNT_DIR=$2 [ $MOUNT_DIR ] && expect_normal_exit run_on_node $1 "sudo umount $MOUNT_DIR &>> $PREP_LOG_FILE" expect_normal_exit run_on_node $1 "$COMMAND_NDCTL_NFIT_TEST_FINI" } # # ndctl_nfit_test_mount_pmem -- mount a pmem block device # # Input arguments: # 1) path of a pmem block device # 2) mount directory # function ndctl_nfit_test_mount_pmem() { FULLDEV=$1 MOUNT_DIR=$2 expect_normal_exit "\ sudo mkfs.ext4 $FULLDEV &>>$PREP_LOG_FILE && \ sudo mkdir -p $MOUNT_DIR &>>$PREP_LOG_FILE && \ sudo mount $FULLDEV $MOUNT_DIR &>>$PREP_LOG_FILE && \ sudo chmod 0777 $MOUNT_DIR" } # # ndctl_nfit_test_mount_pmem_node -- mount a pmem block device on a remote node # # Input arguments: # 1) number of a node # 2) path of a pmem block device # 3) mount directory # function ndctl_nfit_test_mount_pmem_node() { FULLDEV=$2 MOUNT_DIR=$3 expect_normal_exit run_on_node $1 "\ sudo mkfs.ext4 $FULLDEV &>>$PREP_LOG_FILE && \ sudo mkdir -p $MOUNT_DIR &>>$PREP_LOG_FILE && \ sudo mount $FULLDEV $MOUNT_DIR &>>$PREP_LOG_FILE && \ sudo chmod 0777 $MOUNT_DIR" } # # ndctl_nfit_test_get_device -- create a namespace and get name of the pmem device # of the nfit_test module # # Input argument: # 1) mode of the namespace (devdax or fsdax) # function ndctl_nfit_test_get_device() { MODE=$1 DEVTYPE="" [ "$MODE" == "devdax" ] && DEVTYPE="chardev" [ "$MODE" == "fsdax" ] && DEVTYPE="blockdev" [ "$DEVTYPE" == "" ] && echo "ERROR: wrong namespace mode: $MODE" >&2 && exit 1 BUS="nfit_test.0" REGION=$(ndctl list -b $BUS -t pmem -Ri | sed "/dev/!d;s/[\", ]//g;s/dev://g" | tail -1) DEVICE=$(sudo ndctl create-namespace -b $BUS -r $REGION -f -m $MODE -a 4096 | sed "/$DEVTYPE/!d;s/[\", ]//g;s/$DEVTYPE://g") echo $DEVICE } # # ndctl_nfit_test_get_device_node -- create a namespace and get name of the pmem device # of the nfit_test module on a remote node # # Input argument: # 1) mode of the namespace (devdax or fsdax) # function ndctl_nfit_test_get_device_node() { MODE=$2 DEVTYPE="" [ "$MODE" == "devdax" ] && DEVTYPE="chardev" [ "$MODE" == "fsdax" ] && DEVTYPE="blockdev" [ "$DEVTYPE" == "" ] && echo "ERROR: wrong namespace mode: $MODE" >&2 && exit 1 BUS="nfit_test.0" REGION=$(expect_normal_exit run_on_node $1 ndctl list -b $BUS -t pmem -Ri | sed "/dev/!d;s/[\", ]//g;s/dev://g" | tail -1) DEVICE=$(expect_normal_exit run_on_node $1 sudo ndctl create-namespace -b $BUS -r $REGION -f -m $MODE -a 4096 | sed "/$DEVTYPE/!d;s/[\", ]//g;s/$DEVTYPE://g") echo $DEVICE } # # ndctl_nfit_test_get_dax_device -- create a namespace and get name of the dax device # of the nfit_test module # function ndctl_nfit_test_get_dax_device() { # XXX needed by libndctl (it should be removed when it is not needed) sudo chmod o+rw /dev/ndctl* DEVICE=$(ndctl_nfit_test_get_device devdax) sudo chmod o+rw /dev/$DEVICE echo $DEVICE } # # ndctl_nfit_test_get_dax_device_node -- create a namespace and get name of # the pmem dax device of the nfit_test # module on a remote node # function ndctl_nfit_test_get_dax_device_node() { DEVICE=$(ndctl_nfit_test_get_device_node $1 devdax) echo $DEVICE } # # ndctl_nfit_test_get_block_device -- create a namespace and get name of the pmem block device # of the nfit_test module # function ndctl_nfit_test_get_block_device() { DEVICE=$(ndctl_nfit_test_get_device fsdax) echo $DEVICE } # # ndctl_nfit_test_get_block_device_node -- create a namespace and get name of # the pmem block device of the nfit_test # module on a remote node # function ndctl_nfit_test_get_block_device_node() { DEVICE=$(ndctl_nfit_test_get_device_node $1 fsdax) echo $DEVICE } # # ndctl_nfit_test_grant_access -- grant accesses required by libndctl # # XXX needed by libndctl (it should be removed when these extra access rights are not needed) # # Input argument: # 1) a name of pmem device # function ndctl_nfit_test_grant_access() { BUS="nfit_test.0" REGION=$(ndctl list -b $BUS -t pmem -Ri | sed "/dev/!d;s/[\", ]//g;s/dev://g" | tail -1) expect_normal_exit "\ sudo chmod o+rw /dev/nmem* && \ sudo chmod o+r /sys/bus/nd/devices/ndbus*/$REGION/*/resource && \ sudo chmod o+r /sys/bus/nd/devices/ndbus*/$REGION/resource" } # # ndctl_nfit_test_grant_access_node -- grant accesses required by libndctl on a node # # XXX needed by libndctl (it should be removed when these extra access rights are not needed) # # Input arguments: # 1) node number # 2) name of pmem device # function ndctl_nfit_test_grant_access_node() { BUS="nfit_test.0" REGION=$(expect_normal_exit run_on_node $1 ndctl list -b $BUS -t pmem -Ri | sed "/dev/!d;s/[\", ]//g;s/dev://g" | tail -1) expect_normal_exit run_on_node $1 "\ sudo chmod o+rw /dev/nmem* && \ sudo chmod o+r /sys/bus/nd/devices/ndbus*/$REGION/*/resource && \ sudo chmod o+r /sys/bus/nd/devices/ndbus*/$REGION/resource" } # # ndctl_requires_extra_access -- checks whether ndctl will require extra # file permissions for bad-block iteration # # Input argument: # 1) Mode of the namespace # function ndctl_requires_extra_access() { # Tests require additional permissions for badblock iteration if they # are ran on device dax or with ndctl version prior to v63. if [ "$1" != "fsdax" ] || ! is_ndctl_enabled $PMEMPOOL$EXESUFFIX ; then return 0 fi return 1 } # # ndctl_nfit_test_get_namespace_of_device -- get namespace of the pmem device # # Input argument: # 1) a name of pmem device # function ndctl_get_namespace_of_device() { local DEVICE=$1 NAMESPACE=$(ndctl list | grep -e "$DEVICE" -e namespace | grep -B1 -e "$DEVICE" | head -n1 | cut -d'"' -f4) MODE=$(ndctl list -n "$NAMESPACE" | grep mode | cut -d'"' -f4) if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ] && ndctl_requires_extra_access $MODE; then ndctl_nfit_test_grant_access $DEVICE fi echo "$NAMESPACE" } # # ndctl_nfit_test_get_namespace_of_device_node -- get namespace of the pmem device on a remote node # # Input arguments: # 1) node number # 2) name of pmem device # function ndctl_get_namespace_of_device_node() { local DEVICE=$2 NAMESPACE=$(expect_normal_exit run_on_node $1 ndctl list | grep -e "$DEVICE" -e namespace | grep -B1 -e "$DEVICE" | head -n1 | cut -d'"' -f4) MODE=$(expect_normal_exit run_on_node $1 ndctl list -n "$NAMESPACE" | grep mode | cut -d'"' -f4) if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ] && ndctl_requires_extra_access $MODE; then ndctl_nfit_test_grant_access_node $1 $DEVICE fi echo $NAMESPACE } # # ndctl_inject_error -- inject error (bad blocks) to the namespace # # Input arguments: # 1) namespace # 2) the first bad block # 3) number of bad blocks # function ndctl_inject_error() { local namespace=$1 local block=$2 local count=$3 echo "# sudo ndctl inject-error --block=$block --count=$count $namespace" >> $PREP_LOG_FILE expect_normal_exit "sudo ndctl inject-error --block=$block --count=$count $namespace" &>> $PREP_LOG_FILE echo "# sudo ndctl start-scrub" >> $PREP_LOG_FILE expect_normal_exit "sudo ndctl start-scrub" &>> $PREP_LOG_FILE echo "# sudo ndctl wait-scrub" >> $PREP_LOG_FILE expect_normal_exit "sudo ndctl wait-scrub" &>> $PREP_LOG_FILE echo "(done: ndctl wait-scrub)" >> $PREP_LOG_FILE } # # ndctl_inject_error_node -- inject error (bad blocks) to the namespace on # a given remote node # # Input arguments: # 1) node # 2) namespace # 3) the first bad block # 4) number of bad blocks # function ndctl_inject_error_node() { local node=$1 local namespace=$2 local block=$3 local count=$4 echo "# sudo ndctl inject-error --block=$block --count=$count $namespace" >> $PREP_LOG_FILE expect_normal_exit run_on_node $node "sudo ndctl inject-error --block=$block --count=$count $namespace" &>> $PREP_LOG_FILE echo "# sudo ndctl start-scrub" >> $PREP_LOG_FILE expect_normal_exit run_on_node $node "sudo ndctl start-scrub" &>> $PREP_LOG_FILE echo "# sudo ndctl wait-scrub" >> $PREP_LOG_FILE expect_normal_exit run_on_node $node "sudo ndctl wait-scrub" &>> $PREP_LOG_FILE echo "(done: ndctl wait-scrub)" >> $PREP_LOG_FILE } # # ndctl_uninject_error -- clear bad block error present in the namespace # # Input arguments: # 1) full device name (error clearing process requires writing to device) # 2) namespace # 3) the first bad block # 4) number of bad blocks # function ndctl_uninject_error() { # explicit uninjection is not required on nfit_test since any error # injections made during the tests are eventually cleaned up in _fini # function by reloading the whole namespace if [ "$BADBLOCK_TEST_TYPE" == "real_pmem" ]; then local fulldev=$1 local namespace=$2 local block=$3 local count=$4 expect_normal_exit "sudo ndctl inject-error --uninject --block=$block --count=$count $namespace >> $PREP_LOG_FILE 2>&1" if [ "$DEVTYPE" == "block_device" ]; then expect_normal_exit "sudo dd if=/dev/zero of=$fulldev bs=512 seek=$block count=$count \ oflag=direct >> $PREP_LOG_FILE 2>&1" elif [ "$DEVTYPE" == "dax_device" ]; then expect_normal_exit "$DAXIO$EXESUFFIX -i /dev/zero -o $fulldev -s $block -l $count >> $PREP_LOG_FILE 2>&1" fi fi } # # ndctl_uninject_error_node -- clear bad block error present in the # namespace on a given remote node # # Input arguments: # 1) node # 2) full device name (error clearing process requires writing to device) # 3) namespace # 4) the first bad block # 5) number of bad blocks # function ndctl_uninject_error_node() { # explicit uninjection is not required on nfit_test since any error # injections made during the tests are eventually cleaned up in _fini # function by reloading the whole namespace if [ "$BADBLOCK_TEST_TYPE" == "real_pmem" ]; then local node=$1 local fulldev=$2 local namespace=$3 local block=$4 local count=$5 expect_normal_exit run_on_node $node "sudo ndctl inject-error --uninject --block=$block --count=$count \ $namespace >> $PREP_LOG_FILE 2>&1" if [ "$DEVTYPE" == "block_device" ]; then expect_normal_exit run_on_node $node "sudo dd if=/dev/zero of=$fulldev bs=512 seek=$block count=$count \ oflag=direct >> $PREP_LOG_FILE 2>&1" elif [ "$DEVTYPE" == "dax_device" ]; then expect_normal_exit run_on_node $node "$DAXIO$EXESUFFIX -i /dev/zero -o $fulldev -s $block -l $count \ >> $PREP_LOG_FILE 2>&1" fi fi } # # print_bad_blocks -- print all bad blocks (count, offset and length) # in the given namespace or "No bad blocks found" # if there are no bad blocks # # Input arguments: # 1) namespace # function print_bad_blocks { # XXX sudo should be removed when it is not needed sudo ndctl list -M -n $1 | \ grep -e "badblock_count" -e "offset" -e "length" >> $LOG \ || echo "No bad blocks found" >> $LOG } # # expect_bad_blocks -- verify if there are required bad blocks # in the given namespace and fail if they are not there # # Input arguments: # 1) namespace # function expect_bad_blocks { # XXX sudo should be removed when it is not needed sudo ndctl list -M -n $1 | grep -e "badblock_count" -e "offset" -e "length" >> $LOG && true if [ $? -ne 0 ]; then # XXX sudo should be removed when it is not needed sudo ndctl list -M &>> $PREP_LOG_FILE && true msg "=====================================================================" msg "Error occurred, the preparation log ($PREP_LOG_FILE) is listed below:" msg "" cat $PREP_LOG_FILE msg "=====================================================================" msg "" fatal "Error: ndctl failed to inject or retain bad blocks" fi } # # expect_bad_blocks_node -- verify if there are required bad blocks # in the given namespace on the given node # and fail if they are not there # # Input arguments: # 1) node number # 2) namespace # function expect_bad_blocks_node { # XXX sudo should be removed when it is not needed expect_normal_exit run_on_node $1 sudo ndctl list -M -n $2 | \ grep -e "badblock_count" -e "offset" -e "length" >> $LOG \ || fatal "Error: ndctl failed to inject or retain bad blocks (node $1)" }
20,737
28.838849
159
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/libpmempool_rm_remote/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017, Intel Corporation # # # libpmempool_rm_remote/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
285
19.428571
55
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmem_obc/rpmem_obc_test_common.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2018, Intel Corporation */ /* * rpmem_obc_test_common.h -- common declarations for rpmem_obc test */ #include "unittest.h" #include "out.h" #include "librpmem.h" #include "rpmem.h" #include "rpmem_proto.h" #include "rpmem_common.h" #include "rpmem_util.h" #include "rpmem_obc.h" #define POOL_SIZE 1024 #define NLANES 32 #define NLANES_RESP 16 #define PROVIDER RPMEM_PROV_LIBFABRIC_SOCKETS #define POOL_DESC "pool_desc" #define RKEY 0xabababababababab #define RADDR 0x0101010101010101 #define PORT 1234 #define BUFF_SIZE 8192 #define POOL_ATTR_INIT {\ .signature = "<RPMEM>",\ .major = 1,\ .compat_features = 2,\ .incompat_features = 3,\ .ro_compat_features = 4,\ .poolset_uuid = "POOLSET_UUID0123",\ .uuid = "UUID0123456789AB",\ .next_uuid = "NEXT_UUID0123456",\ .prev_uuid = "PREV_UUID0123456",\ .user_flags = "USER_FLAGS012345",\ } #define POOL_ATTR_ALT {\ .signature = "<ALT>",\ .major = 5,\ .compat_features = 6,\ .incompat_features = 7,\ .ro_compat_features = 8,\ .poolset_uuid = "UUID_POOLSET_ALT",\ .uuid = "ALT_UUIDCDEFFEDC",\ .next_uuid = "456UUID_NEXT_ALT",\ .prev_uuid = "UUID012_ALT_PREV",\ .user_flags = "012345USER_FLAGS",\ } static const struct rpmem_pool_attr POOL_ATTR = POOL_ATTR_INIT; struct server { int fd_in; int fd_out; }; void set_rpmem_cmd(const char *fmt, ...); struct server *srv_init(void); void srv_fini(struct server *s); void srv_recv(struct server *s, void *buff, size_t len); void srv_send(struct server *s, const void *buff, size_t len); void srv_wait_disconnect(struct server *s); void client_connect_wait(struct rpmem_obc *rpc, char *target); /* * Since the server may disconnect the connection at any moment * from the client's perspective, execute the test in a loop so * the moment when the connection is closed will be possibly different. */ #define ECONNRESET_LOOP 10 void server_econnreset(struct server *s, const void *msg, size_t len); TEST_CASE_DECLARE(client_enotconn); TEST_CASE_DECLARE(client_connect); TEST_CASE_DECLARE(client_monitor); TEST_CASE_DECLARE(server_monitor); TEST_CASE_DECLARE(server_wait); TEST_CASE_DECLARE(client_create); TEST_CASE_DECLARE(server_create); TEST_CASE_DECLARE(server_create_econnreset); TEST_CASE_DECLARE(server_create_eproto); TEST_CASE_DECLARE(server_create_error); TEST_CASE_DECLARE(client_open); TEST_CASE_DECLARE(server_open); TEST_CASE_DECLARE(server_open_econnreset); TEST_CASE_DECLARE(server_open_eproto); TEST_CASE_DECLARE(server_open_error); TEST_CASE_DECLARE(client_close); TEST_CASE_DECLARE(server_close); TEST_CASE_DECLARE(server_close_econnreset); TEST_CASE_DECLARE(server_close_eproto); TEST_CASE_DECLARE(server_close_error); TEST_CASE_DECLARE(client_set_attr); TEST_CASE_DECLARE(server_set_attr); TEST_CASE_DECLARE(server_set_attr_econnreset); TEST_CASE_DECLARE(server_set_attr_eproto); TEST_CASE_DECLARE(server_set_attr_error);
2,951
26.082569
71
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmem_obc/setup.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2019, Intel Corporation # # src/test/rpmem_obc/setup.sh -- common setup for rpmem_obc tests # set -e require_nodes 2 require_node_log_files 1 $RPMEM_LOG_FILE RPMEM_CMD="\"cd ${NODE_TEST_DIR[0]} && UNITTEST_FORCE_QUIET=1 \ LD_LIBRARY_PATH=${NODE_LD_LIBRARY_PATH[0]}:$REMOTE_LD_LIBRARY_PATH \ ./rpmem_obc$EXESUFFIX\"" export_vars_node 1 RPMEM_CMD
428
22.833333
69
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmem2_granularity/pmem2_granularity.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2019, Intel Corporation */ /* * pmem2_granularity.h -- header file for windows mocks * for pmem2_granularity */ #ifndef PMEM2_GRANULARITY_H #define PMEM2_GRANULARITY_H 1 extern size_t Is_nfit; extern size_t Pc_type; extern size_t Pc_capabilities; #endif
314
18.6875
55
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmem2_granularity/mocks_dax_windows.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2019, Intel Corporation */ /* * mocks_dax_windows.h -- redefinitions of GetVolumeInformationByHandleW * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmem2 * files, when compiled for the purpose of pmem2_granularity test. * It would replace default implementation with mocked functions defined * in mocks_windows.c * * This WRAP_REAL define could also be passed as a preprocessor definition. */ #ifndef MOCKS_WINDOWS_H #define MOCKS_WINDOWS_H 1 #include <windows.h> #ifndef WRAP_REAL #define GetVolumeInformationByHandleW __wrap_GetVolumeInformationByHandleW BOOL __wrap_GetVolumeInformationByHandleW(HANDLE hFile, LPWSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, LPDWORD lpVolumeSerialNumber, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, LPWSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize); #endif #endif
956
28.90625
77
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmempool_sync_remote/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2018, Intel Corporation # # # pmempool_sync_remote/config.sh -- test configuration # CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
265
19.461538
54
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmempool_sync_remote/common.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2020, Intel Corporation # # # pmempool_sync_remote/common.sh -- pmempool sync with remote replication # set -e require_nodes 2 require_node_libfabric 0 $RPMEM_PROVIDER require_node_libfabric 1 $RPMEM_PROVIDER setup init_rpmem_on_node 1 0 require_node_log_files 1 pmemobj$UNITTEST_NUM.log require_node_log_files 1 pmempool$UNITTEST_NUM.log PMEMOBJCLI_SCRIPT="pmemobjcli.script" copy_files_to_node 1 ${NODE_TEST_DIR[1]} $PMEMOBJCLI_SCRIPT POOLSET_LOCAL="local_pool.set" # # configure_poolsets -- configure pool set files for test # usage: configure_poolsets <local replicas> <remote replicas> # function configure_poolsets() { local n_local=$1 local n_remote=$2 local poolset_args="8M:${NODE_DIR[1]}/pool.part.1:x 8M:${NODE_DIR[1]}/pool.part.2:x" for i in $(seq 0 $((n_local - 1))); do poolset_args="$poolset_args R 8M:${NODE_DIR[1]}/pool.$i.part.1:x 8M:${NODE_DIR[1]}/pool.$i.part.2:x" done for i in $(seq 0 $((n_remote - 1))); do POOLSET_REMOTE[$i]="remote_pool.$i.set" create_poolset $DIR/${POOLSET_REMOTE[$i]}\ 8M:${NODE_DIR[0]}remote.$i.part.1:x\ 8M:${NODE_DIR[0]}remote.$i.part.2:x copy_files_to_node 0 ${NODE_DIR[0]} $DIR/${POOLSET_REMOTE[$i]} poolset_args="$poolset_args m ${NODE_ADDR[0]}:${POOLSET_REMOTE[$i]}" done create_poolset $DIR/$POOLSET_LOCAL $poolset_args copy_files_to_node 1 ${NODE_DIR[1]} $DIR/$POOLSET_LOCAL expect_normal_exit run_on_node 1 ../pmempool rm -sf ${NODE_DIR[1]}$POOLSET_LOCAL expect_normal_exit run_on_node 1 ../pmempool create obj ${NODE_DIR[1]}$POOLSET_LOCAL expect_normal_exit run_on_node 1 ../pmemobjcli -s $PMEMOBJCLI_SCRIPT ${NODE_DIR[1]}$POOLSET_LOCAL > /dev/null } DUMP_INFO_LOG="../pmempool info -lHZCOoAa" DUMP_INFO_LOG_REMOTE="$DUMP_INFO_LOG -f obj" DUMP_INFO_SED="sed -e '/^Checksum/d' -e '/^Creation/d'" DUMP_INFO_SED_REMOTE="$DUMP_INFO_SED -e '/^Previous part UUID/d' -e '/^Next part UUID/d'" function dump_info_log() { local node=$1 local rep=$2 local poolset=$3 local name=$4 local ignore=$5 local sed_cmd="$DUMP_INFO_SED" if [ -n "$ignore" ]; then sed_cmd="$sed_cmd -e '/^$ignore/d'" fi expect_normal_exit run_on_node $node "\"$DUMP_INFO_LOG -p $rep $poolset | $sed_cmd > $name\"" } function dump_info_log_remote() { local node=$1 local poolset=$2 local name=$3 local ignore=$4 local sed_cmd="$DUMP_INFO_SED_REMOTE" if [ -n "$ignore" ]; then sed_cmd="$sed_cmd -e '/^$ignore/d'" fi expect_normal_exit run_on_node $node "\"$DUMP_INFO_LOG_REMOTE $poolset | $sed_cmd > $name\"" } function diff_log() { local node=$1 local f1=$2 local f2=$3 expect_normal_exit run_on_node $node "\"[ -s $f1 ] && [ -s $f2 ] && diff $f1 $f2\"" } exec_pmemobjcli_script() { local node=$1 local script=$2 local poolset=$3 local out=$4 expect_normal_exit run_on_node $node "\"../pmemobjcli -s $script $poolset > $out \"" }
2,911
25
110
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmempool_sync/setup.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2020, IBM Corporation # PARTSIZE=$(($(getconf PAGESIZE)/1024*2)) POOLSIZE_REP=$(($PARTSIZE*3))
168
20.125
40
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmem_fip/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2017, Intel Corporation # # # src/test/rpmem_fip/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=none CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
288
19.642857
52
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmem_fip/rpmem_fip_oob.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016, Intel Corporation */ /* * rpmem_fip_sock.h -- simple oob connection implementation for exchanging * required RDMA related data */ #include <stdint.h> #include <netinet/in.h> typedef struct rpmem_ssh client_t; client_t *client_exchange(struct rpmem_target_info *info, unsigned nlanes, enum rpmem_provider provider, struct rpmem_resp_attr *resp); void client_close_begin(client_t *c); void client_close_end(client_t *c); void server_exchange_begin(unsigned *lanes, enum rpmem_provider *provider, char **addr); void server_exchange_end(struct rpmem_resp_attr resp); void server_close_begin(void); void server_close_end(void); void set_rpmem_cmd(const char *fmt, ...);
743
24.655172
74
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmem_fip/setup.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2019, Intel Corporation # # src/test/rpmem_fip/setup.sh -- common setup for rpmem_fip tests # set -e require_nodes 2 require_node_libfabric 0 $RPMEM_PROVIDER require_node_libfabric 1 $RPMEM_PROVIDER require_node_log_files 0 $RPMEM_LOG_FILE $RPMEMD_LOG_FILE require_node_log_files 1 $RPMEM_LOG_FILE $RPMEMD_LOG_FILE SRV=srv${UNITTEST_NUM}.pid clean_remote_node 0 $SRV RPMEM_CMD="\"cd ${NODE_TEST_DIR[0]} && RPMEMD_LOG_LEVEL=\$RPMEMD_LOG_LEVEL RPMEMD_LOG_FILE=\$RPMEMD_LOG_FILE UNITTEST_FORCE_QUIET=1 \ LD_LIBRARY_PATH=${NODE_LD_LIBRARY_PATH[0]}:$REMOTE_LD_LIBRARY_PATH \ ./rpmem_fip$EXESUFFIX\"" export_vars_node 1 RPMEM_CMD if [ -n ${RPMEM_MAX_NLANES+x} ]; then export_vars_node 1 RPMEM_MAX_NLANES fi
786
28.148148
133
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/tools/anonymous_mmap/check_max_mmap.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2018, Intel Corporation # # src/test/tools/anonymous_mmap/check_max_mmap.sh -- checks how many DAX # devices can be mapped under Valgrind and saves the number in # src/test/tools/anonymous_mmap/max_dax_devices. # DIR_CHECK_MAX_MMAP="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" FILE_MAX_DAX_DEVICES="$DIR_CHECK_MAX_MMAP/max_dax_devices" ANONYMOUS_MMAP="$DIR_CHECK_MAX_MMAP/anonymous_mmap.static-nondebug" source "$DIR_CHECK_MAX_MMAP/../../testconfig.sh" # # get_devdax_size -- get the size of a device dax # function get_devdax_size() { local device=$1 local path=${DEVICE_DAX_PATH[$device]} local major_hex=$(stat -c "%t" $path) local minor_hex=$(stat -c "%T" $path) local major_dec=$((16#$major_hex)) local minor_dec=$((16#$minor_hex)) cat /sys/dev/char/$major_dec:$minor_dec/size } function msg_skip() { echo "0" > "$FILE_MAX_DAX_DEVICES" echo "$0: SKIP: $*" exit 0 } function msg_failed() { echo "$0: FATAL: $*" >&2 exit 1 } # check if DEVICE_DAX_PATH specifies at least one DAX device if [ ${#DEVICE_DAX_PATH[@]} -lt 1 ]; then msg_skip "DEVICE_DAX_PATH does not specify path to DAX device." fi # check if valgrind package is installed VALGRINDEXE=`which valgrind 2>/dev/null` ret=$? if [ $ret -ne 0 ]; then msg_skip "Valgrind required." fi # check if memcheck tool is installed $VALGRINDEXE --tool=memcheck --help 2>&1 | grep -qi "memcheck is Copyright (c)" && true if [ $? -ne 0 ]; then msg_skip "Valgrind with memcheck required." fi # check if anonymous_mmap tool is built if [ ! -f "${ANONYMOUS_MMAP}" ]; then msg_failed "${ANONYMOUS_MMAP} does not exist" fi # checks how many DAX devices can be mmapped under Valgrind and save the number # in $FILE_MAX_DAX_DEVICES file bytes="0" max_devices="0" for index in ${!DEVICE_DAX_PATH[@]} do if [ ! -e "${DEVICE_DAX_PATH[$index]}" ]; then msg_failed "${DEVICE_DAX_PATH[$index]} does not exist" fi curr=$(get_devdax_size $index) if [[ curr -eq 0 ]]; then msg_failed "size of DAX device pointed by DEVICE_DAX_PATH[$index] equals 0." fi $VALGRINDEXE --tool=memcheck --quiet $ANONYMOUS_MMAP $((bytes + curr)) status=$? if [[ status -ne 0 ]]; then break fi bytes=$((bytes + curr)) max_devices=$((max_devices + 1)) done echo "$max_devices" > "$FILE_MAX_DAX_DEVICES" echo "$0: maximum possible anonymous mmap under Valgrind: $bytes bytes, equals to size of $max_devices DAX device(s). Value saved in $FILE_MAX_DAX_DEVICES."
2,524
26.445652
156
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/tools/ctrld/signals_linux.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017, Intel Corporation */ /* * signals_linux.h - Signal definitions for Linux */ #ifndef _SIGNALS_LINUX_H #define _SIGNALS_LINUX_H 1 #define SIGNAL_2_STR(sig) [sig] = #sig static const char *signal2str[] = { SIGNAL_2_STR(SIGHUP), /* 1 */ SIGNAL_2_STR(SIGINT), /* 2 */ SIGNAL_2_STR(SIGQUIT), /* 3 */ SIGNAL_2_STR(SIGILL), /* 4 */ SIGNAL_2_STR(SIGTRAP), /* 5 */ SIGNAL_2_STR(SIGABRT), /* 6 */ SIGNAL_2_STR(SIGBUS), /* 7 */ SIGNAL_2_STR(SIGFPE), /* 8 */ SIGNAL_2_STR(SIGKILL), /* 9 */ SIGNAL_2_STR(SIGUSR1), /* 10 */ SIGNAL_2_STR(SIGSEGV), /* 11 */ SIGNAL_2_STR(SIGUSR2), /* 12 */ SIGNAL_2_STR(SIGPIPE), /* 13 */ SIGNAL_2_STR(SIGALRM), /* 14 */ SIGNAL_2_STR(SIGTERM), /* 15 */ SIGNAL_2_STR(SIGSTKFLT), /* 16 */ SIGNAL_2_STR(SIGCHLD), /* 17 */ SIGNAL_2_STR(SIGCONT), /* 18 */ SIGNAL_2_STR(SIGSTOP), /* 19 */ SIGNAL_2_STR(SIGTSTP), /* 20 */ SIGNAL_2_STR(SIGTTIN), /* 21 */ SIGNAL_2_STR(SIGTTOU), /* 22 */ SIGNAL_2_STR(SIGURG), /* 23 */ SIGNAL_2_STR(SIGXCPU), /* 24 */ SIGNAL_2_STR(SIGXFSZ), /* 25 */ SIGNAL_2_STR(SIGVTALRM), /* 26 */ SIGNAL_2_STR(SIGPROF), /* 27 */ SIGNAL_2_STR(SIGWINCH), /* 28 */ SIGNAL_2_STR(SIGPOLL), /* 29 */ SIGNAL_2_STR(SIGPWR), /* 30 */ SIGNAL_2_STR(SIGSYS) /* 31 */ }; #define SIGNALMAX SIGSYS #endif
1,322
27.148936
49
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/tools/ctrld/signals_freebsd.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017, Intel Corporation */ /* * signals_fbsd.h - Signal definitions for FreeBSD */ #ifndef _SIGNALS_FBSD_H #define _SIGNALS_FBSD_H 1 #define SIGNAL_2_STR(sig) [sig] = #sig static const char *signal2str[] = { SIGNAL_2_STR(SIGHUP), /* 1 */ SIGNAL_2_STR(SIGINT), /* 2 */ SIGNAL_2_STR(SIGQUIT), /* 3 */ SIGNAL_2_STR(SIGILL), /* 4 */ SIGNAL_2_STR(SIGTRAP), /* 5 */ SIGNAL_2_STR(SIGABRT), /* 6 */ SIGNAL_2_STR(SIGEMT), /* 7 */ SIGNAL_2_STR(SIGFPE), /* 8 */ SIGNAL_2_STR(SIGKILL), /* 9 */ SIGNAL_2_STR(SIGBUS), /* 10 */ SIGNAL_2_STR(SIGSEGV), /* 11 */ SIGNAL_2_STR(SIGSYS), /* 12 */ SIGNAL_2_STR(SIGPIPE), /* 13 */ SIGNAL_2_STR(SIGALRM), /* 14 */ SIGNAL_2_STR(SIGTERM), /* 15 */ SIGNAL_2_STR(SIGURG), /* 16 */ SIGNAL_2_STR(SIGSTOP), /* 17 */ SIGNAL_2_STR(SIGTSTP), /* 18 */ SIGNAL_2_STR(SIGCONT), /* 19 */ SIGNAL_2_STR(SIGCHLD), /* 20 */ SIGNAL_2_STR(SIGTTIN), /* 21 */ SIGNAL_2_STR(SIGTTOU), /* 22 */ SIGNAL_2_STR(SIGIO), /* 23 */ SIGNAL_2_STR(SIGXCPU), /* 24 */ SIGNAL_2_STR(SIGXFSZ), /* 25 */ SIGNAL_2_STR(SIGVTALRM), /* 26 */ SIGNAL_2_STR(SIGPROF), /* 27 */ SIGNAL_2_STR(SIGWINCH), /* 28 */ SIGNAL_2_STR(SIGINFO), /* 29 */ SIGNAL_2_STR(SIGUSR1), /* 30 */ SIGNAL_2_STR(SIGUSR2), /* 31 */ SIGNAL_2_STR(SIGTHR), /* 32 */ SIGNAL_2_STR(SIGLIBRT) /* 33 */ }; #define SIGNALMAX SIGLIBRT #endif
1,386
26.74
50
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/libpmempool_feature/common.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2018-2019, Intel Corporation # # src/test/libpmempool_feature/common.sh -- common part of libpmempool_feature tests # POOL=$DIR/pool.obj OUT=out${UNITTEST_NUM}.log LOG=grep${UNITTEST_NUM}.log QUERY_PATTERN="query" ERROR_PATTERN="<1> \\[feature.c:.*\\]" exit_func=expect_normal_exit sds_enabled=$(is_ndctl_enabled ./libpmempool_feature$EXESUFFIX; echo $?) # libpmempool_feature_query_abnormal -- query feature with expected # abnormal result # # usage: libpmempool_feature_query_abnormal <enum-pmempool_feature> function libpmempool_feature_query_abnormal() { # query feature expect_abnormal_exit ./libpmempool_feature$EXESUFFIX $POOL q $1 if [ -f "$PMEMPOOL_LOG_FILE" ]; then cat $PMEMPOOL_LOG_FILE | grep "$ERROR_PATTERN" >> $LOG fi } # libpmempool_feature_query -- query feature # # usage: libpmempool_feature_query <enum-pmempool_feature> function libpmempool_feature_query() { # query feature expect_normal_exit ./libpmempool_feature$EXESUFFIX $POOL q $1 cat $OUT | grep "$QUERY_PATTERN" >> $LOG # verify query with pmempool info set +e count=$(expect_normal_exit $PMEMPOOL$EXESUFFIX info $POOL | grep -c "$1") set -e if [ "$count" = "0" ]; then echo "pmempool info: $1 is NOT set" >> $LOG else echo "pmempool info: $1 is set" >> $LOG fi # check if pool is still valid expect_normal_exit $PMEMPOOL$EXESUFFIX check $POOL >> /dev/null } # libpmempool_feature_enable -- enable feature # # usage: libpmempool_feature_enable <enum-pmempool_feature> [no-query] function libpmempool_feature_enable() { $exit_func ./libpmempool_feature$EXESUFFIX $POOL e $1 if [ "$exit_func" == "expect_abnormal_exit" ]; then if [ -f "$PMEMPOOL_LOG_FILE" ]; then cat $PMEMPOOL_LOG_FILE | grep "$ERROR_PATTERN" >> $LOG fi fi if [ "x$2" != "xno-query" ]; then libpmempool_feature_query $1 fi } # libpmempool_feature_disable -- disable feature # # usage: libpmempool_feature_disable <enum-pmempool_feature> [no-query] function libpmempool_feature_disable() { $exit_func ./libpmempool_feature$EXESUFFIX $POOL d $1 if [ "$exit_func" == "expect_abnormal_exit" ]; then if [ -f "$PMEMPOOL_LOG_FILE" ]; then cat $PMEMPOOL_LOG_FILE | grep "$ERROR_PATTERN" >> $LOG fi fi if [ "x$2" != "xno-query" ]; then libpmempool_feature_query $1 fi }
2,340
27.204819
84
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmem2_memset/memset_common.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2020, Intel Corporation */ /* * memset_common.h -- header file for common memset utilities */ #ifndef MEMSET_COMMON_H #define MEMSET_COMMON_H 1 #include "unittest.h" #include "file.h" extern unsigned Flags[10]; typedef void *(*memset_fn)(void *pmemdest, int c, size_t len, unsigned flags); typedef void (*persist_fn)(const void *ptr, size_t len); void do_memset(int fd, char *dest, const char *file_name, size_t dest_off, size_t bytes, memset_fn fn, unsigned flags, persist_fn p); #endif
552
22.041667
78
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/sync-remotes/copy-to-remote-nodes.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2018, Intel Corporation # # copy-to-remote-nodes.sh -- helper script used to sync remote nodes # set -e if [ ! -f ../testconfig.sh ]; then echo "SKIP: testconfig.sh does not exist" exit 0 fi # defined only to be able to source unittest.sh UNITTEST_NAME=sync-remotes UNITTEST_NUM=0 # Override default FS (any). # This is not a real test, so it should not depend on whether # PMEM_FS_DIR/NON_PMEM_FS_DIR are set. FS=none . ../unittest/unittest.sh COPY_TYPE=$1 shift case "$COPY_TYPE" in common) copy_common_to_remote_nodes $* > /dev/null exit 0 ;; test) copy_test_to_remote_nodes $* > /dev/null exit 0 ;; esac echo "Error: unknown copy type: $COPY_TYPE" exit 1
788
17.785714
68
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmempool_check/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017, Intel Corporation # # # pmempool_check/config.sh -- test configuration # # Extend timeout for TEST5, as it may take a few minutes # when run on a non-pmem file system. CONF_TIMEOUT[5]='10m'
271
18.428571
56
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmempool_check/common.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2018-2020, Intel Corporation # # # pmempool_check/common.sh -- checking pools helpers # LOG=out${UNITTEST_NUM}.log rm -f $LOG && touch $LOG LAYOUT=OBJ_LAYOUT$SUFFIX POOLSET=$DIR/poolset # pmemspoil_corrupt_replica_sds -- corrupt shutdown state # # usage: pmemspoil_corrupt_replica_sds <replica> function pmemspoil_corrupt_replica_sds() { local replica=$1 expect_normal_exit $PMEMSPOIL --replica $replica $POOLSET \ pool_hdr.shutdown_state.usc=999 \ pool_hdr.shutdown_state.dirty=1 \ "pool_hdr.shutdown_state.f:checksum_gen" } # pmempool_check_sds_init -- shutdown state unittest init # # usage: pmempool_check_sds [enable-sds] function pmempool_check_sds_init() { # initialize poolset create_poolset $POOLSET \ 8M:$DIR/part00:x \ r 8M:$DIR/part10:x # enable SHUTDOWN_STATE feature if [ "x$1" == "xenable-sds" ]; then local conf="sds.at_create=1" fi PMEMOBJ_CONF="${PMEMOBJ_CONF}$conf;" expect_normal_exit $PMEMPOOL$EXESUFFIX create --layout=$LAYOUT obj $POOLSET } # pmempool_check_sds -- perform shutdown state unittest # # usage: pmempool_check_sds <scenario> function pmempool_check_sds() { # corrupt poolset replicas pmemspoil_corrupt_replica_sds 0 pmemspoil_corrupt_replica_sds 1 # verify it is corrupted expect_abnormal_exit $PMEMPOOL$EXESUFFIX check $POOLSET >> $LOG 2>/dev/null exit_func=expect_normal_exit # perform fixes case "$1" in fix_second_replica_only) echo -e "n\ny\n" | expect_normal_exit $PMEMPOOL$EXESUFFIX check -vr $POOLSET >> $LOG 2>/dev/null ;; fix_first_replica) echo -e "y\n" | expect_normal_exit $PMEMPOOL$EXESUFFIX check -vr $POOLSET >> $LOG 2>/dev/null ;; fix_no_replicas) echo -e "n\nn\n" | expect_abnormal_exit $PMEMPOOL$EXESUFFIX check -vr $POOLSET >> $LOG 2>/dev/null exit_func=expect_abnormal_exit ;; *) fatal "unittest_sds: undefined scenario '$1'" ;; esac #verify result $exit_func $PMEMPOOL$EXESUFFIX check $POOLSET >> $LOG 2>/dev/null }
2,010
25.460526
100
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/unittest/unittest.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2014-2020, Intel Corporation */ /* * unittest.h -- the mundane stuff shared by all unit tests * * we want unit tests to be very thorough and check absolutely everything * in order to nail down the test case as precisely as possible and flag * anything at all unexpected. as a result, most unit tests are 90% code * checking stuff that isn't really interesting to what is being tested. * to help address this, the macros defined here include all the boilerplate * error checking which prints information and exits on unexpected errors. * * the result changes this code: * * if ((buf = malloc(size)) == NULL) { * fprintf(stderr, "cannot allocate %d bytes for buf\n", size); * exit(1); * } * * into this code: * * buf = MALLOC(size); * * and the error message includes the calling context information (file:line). * in general, using the all-caps version of a call means you're using the * unittest.h version which does the most common checking for you. so * calling VMEM_CREATE() instead of vmem_create() returns the same * thing, but can never return an error since the unit test library checks for * it. * for routines like vmem_delete() there is no corresponding * VMEM_DELETE() because there's no error to check for. * * all unit tests should use the same initialization: * * START(argc, argv, "brief test description", ...); * * all unit tests should use these exit calls: * * DONE("message", ...); * UT_FATAL("message", ...); * * uniform stderr and stdout messages: * * UT_OUT("message", ...); * UT_ERR("message", ...); * * in all cases above, the message is printf-like, taking variable args. * the message can be NULL. it can start with "!" in which case the "!" is * skipped and the message gets the errno string appended to it, like this: * * if (somesyscall(..) < 0) * UT_FATAL("!my message"); */ #ifndef _UNITTEST_H #define _UNITTEST_H 1 #include <libpmem.h> #include <libpmem2.h> #include <libpmemblk.h> #include <libpmemlog.h> #include <libpmemobj.h> #include <libpmempool.h> #ifdef __cplusplus extern "C" { #endif #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <stdarg.h> #include <stdint.h> #include <string.h> #include <strings.h> #include <setjmp.h> #include <time.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <sys/mman.h> #include <sys/file.h> #ifndef __FreeBSD__ #include <sys/mount.h> #endif #include <fcntl.h> #include <signal.h> #include <errno.h> #include <dirent.h> /* XXX: move OS abstraction layer out of common */ #include "os.h" #include "os_thread.h" #include "util.h" int ut_get_uuid_str(char *); #define UT_MAX_ERR_MSG 128 #define UT_POOL_HDR_UUID_STR_LEN 37 /* uuid string length */ #define UT_POOL_HDR_UUID_GEN_FILE "/proc/sys/kernel/random/uuid" /* XXX - fix this temp hack dup'ing util_strerror when we get mock for win */ void ut_strerror(int errnum, char *buff, size_t bufflen); /* XXX - eliminate duplicated definitions in unittest.h and util.h */ #ifdef _WIN32 static inline int ut_util_statW(const wchar_t *path, os_stat_t *st_bufp) { int retVal = _wstat64(path, st_bufp); /* clear unused bits to avoid confusion */ st_bufp->st_mode &= 0600; return retVal; } #endif /* * unit test support... */ void ut_start(const char *file, int line, const char *func, int argc, char * const argv[], const char *fmt, ...) __attribute__((format(printf, 6, 7))); void ut_startW(const char *file, int line, const char *func, int argc, wchar_t * const argv[], const char *fmt, ...) __attribute__((format(printf, 6, 7))); void NORETURN ut_done(const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf, 4, 5))); void NORETURN ut_fatal(const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf, 4, 5))); void NORETURN ut_end(const char *file, int line, const char *func, int ret); void ut_out(const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf, 4, 5))); void ut_err(const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf, 4, 5))); /* indicate the start of the test */ #ifndef _WIN32 #define START(argc, argv, ...)\ ut_start(__FILE__, __LINE__, __func__, argc, argv, __VA_ARGS__) #else #define START(argc, argv, ...)\ wchar_t **wargv = CommandLineToArgvW(GetCommandLineW(), &argc);\ for (int i = 0; i < argc; i++) {\ argv[i] = ut_toUTF8(wargv[i]);\ if (argv[i] == NULL) {\ for (i--; i >= 0; i--)\ free(argv[i]);\ UT_FATAL("Error during arguments conversion\n");\ }\ }\ ut_start(__FILE__, __LINE__, __func__, argc, argv, __VA_ARGS__) #endif /* indicate the start of the test */ #define STARTW(argc, argv, ...)\ ut_startW(__FILE__, __LINE__, __func__, argc, argv, __VA_ARGS__) /* normal exit from test */ #ifndef _WIN32 #define DONE(...)\ ut_done(__FILE__, __LINE__, __func__, __VA_ARGS__) #else #define DONE(...)\ for (int i = argc; i > 0; i--)\ free(argv[i - 1]);\ ut_done(__FILE__, __LINE__, __func__, __VA_ARGS__) #endif #define DONEW(...)\ ut_done(__FILE__, __LINE__, __func__, __VA_ARGS__) #define END(ret, ...)\ ut_end(__FILE__, __LINE__, __func__, ret) /* fatal error detected */ #define UT_FATAL(...)\ ut_fatal(__FILE__, __LINE__, __func__, __VA_ARGS__) /* normal output */ #define UT_OUT(...)\ ut_out(__FILE__, __LINE__, __func__, __VA_ARGS__) /* error output */ #define UT_ERR(...)\ ut_err(__FILE__, __LINE__, __func__, __VA_ARGS__) /* * assertions... */ /* assert a condition is true at runtime */ #define UT_ASSERT_rt(cnd)\ ((void)((cnd) || (ut_fatal(__FILE__, __LINE__, __func__,\ "assertion failure: %s", #cnd), 0))) /* assertion with extra info printed if assertion fails at runtime */ #define UT_ASSERTinfo_rt(cnd, info) \ ((void)((cnd) || (ut_fatal(__FILE__, __LINE__, __func__,\ "assertion failure: %s (%s)", #cnd, info), 0))) /* assert two integer values are equal at runtime */ #define UT_ASSERTeq_rt(lhs, rhs)\ ((void)(((lhs) == (rhs)) || (ut_fatal(__FILE__, __LINE__, __func__,\ "assertion failure: %s (0x%llx) == %s (0x%llx)", #lhs,\ (unsigned long long)(lhs), #rhs, (unsigned long long)(rhs)), 0))) /* assert two integer values are not equal at runtime */ #define UT_ASSERTne_rt(lhs, rhs)\ ((void)(((lhs) != (rhs)) || (ut_fatal(__FILE__, __LINE__, __func__,\ "assertion failure: %s (0x%llx) != %s (0x%llx)", #lhs,\ (unsigned long long)(lhs), #rhs, (unsigned long long)(rhs)), 0))) #if defined(__CHECKER__) #define UT_COMPILE_ERROR_ON(cond) #define UT_ASSERT_COMPILE_ERROR_ON(cond) #elif defined(_MSC_VER) #define UT_COMPILE_ERROR_ON(cond) C_ASSERT(!(cond)) /* XXX - can't be done with C_ASSERT() unless we have __builtin_constant_p() */ #define UT_ASSERT_COMPILE_ERROR_ON(cond) (void)(cond) #else #define UT_COMPILE_ERROR_ON(cond) ((void)sizeof(char[(cond) ? -1 : 1])) #ifndef __cplusplus #define UT_ASSERT_COMPILE_ERROR_ON(cond) UT_COMPILE_ERROR_ON(cond) #else /* __cplusplus */ /* * XXX - workaround for https://github.com/pmem/issues/issues/189 */ #define UT_ASSERT_COMPILE_ERROR_ON(cond) UT_ASSERT_rt(!(cond)) #endif /* __cplusplus */ #endif /* _MSC_VER */ /* assert a condition is true */ #define UT_ASSERT(cnd)\ do {\ /*\ * Detect useless asserts on always true expression. Please use\ * UT_COMPILE_ERROR_ON(!cnd) or UT_ASSERT_rt(cnd) in such\ * cases.\ */\ if (__builtin_constant_p(cnd))\ UT_ASSERT_COMPILE_ERROR_ON(cnd);\ UT_ASSERT_rt(cnd);\ } while (0) /* assertion with extra info printed if assertion fails */ #define UT_ASSERTinfo(cnd, info) \ do {\ /* See comment in UT_ASSERT. */\ if (__builtin_constant_p(cnd))\ UT_ASSERT_COMPILE_ERROR_ON(cnd);\ UT_ASSERTinfo_rt(cnd, info);\ } while (0) /* assert two integer values are equal */ #define UT_ASSERTeq(lhs, rhs)\ do {\ /* See comment in UT_ASSERT. */\ if (__builtin_constant_p(lhs) && __builtin_constant_p(rhs))\ UT_ASSERT_COMPILE_ERROR_ON((lhs) == (rhs));\ UT_ASSERTeq_rt(lhs, rhs);\ } while (0) /* assert two integer values are not equal */ #define UT_ASSERTne(lhs, rhs)\ do {\ /* See comment in UT_ASSERT. */\ if (__builtin_constant_p(lhs) && __builtin_constant_p(rhs))\ UT_ASSERT_COMPILE_ERROR_ON((lhs) != (rhs));\ UT_ASSERTne_rt(lhs, rhs);\ } while (0) /* assert pointer is fits range of [start, start + size) */ #define UT_ASSERTrange(ptr, start, size)\ ((void)(((uintptr_t)(ptr) >= (uintptr_t)(start) &&\ (uintptr_t)(ptr) < (uintptr_t)(start) + (uintptr_t)(size)) ||\ (ut_fatal(__FILE__, __LINE__, __func__,\ "assert failure: %s (%p) is outside range [%s (%p), %s (%p))", #ptr,\ (void *)(ptr), #start, (void *)(start), #start"+"#size,\ (void *)((uintptr_t)(start) + (uintptr_t)(size))), 0))) /* * memory allocation... */ void *ut_malloc(const char *file, int line, const char *func, size_t size); void *ut_calloc(const char *file, int line, const char *func, size_t nmemb, size_t size); void ut_free(const char *file, int line, const char *func, void *ptr); void ut_aligned_free(const char *file, int line, const char *func, void *ptr); void *ut_realloc(const char *file, int line, const char *func, void *ptr, size_t size); char *ut_strdup(const char *file, int line, const char *func, const char *str); void *ut_pagealignmalloc(const char *file, int line, const char *func, size_t size); void *ut_memalign(const char *file, int line, const char *func, size_t alignment, size_t size); void *ut_mmap_anon_aligned(const char *file, int line, const char *func, size_t alignment, size_t size); int ut_munmap_anon_aligned(const char *file, int line, const char *func, void *start, size_t size); /* a malloc() that can't return NULL */ #define MALLOC(size)\ ut_malloc(__FILE__, __LINE__, __func__, size) /* a calloc() that can't return NULL */ #define CALLOC(nmemb, size)\ ut_calloc(__FILE__, __LINE__, __func__, nmemb, size) /* a malloc() of zeroed memory */ #define ZALLOC(size)\ ut_calloc(__FILE__, __LINE__, __func__, 1, size) #define FREE(ptr)\ ut_free(__FILE__, __LINE__, __func__, ptr) #define ALIGNED_FREE(ptr)\ ut_aligned_free(__FILE__, __LINE__, __func__, ptr) /* a realloc() that can't return NULL */ #define REALLOC(ptr, size)\ ut_realloc(__FILE__, __LINE__, __func__, ptr, size) /* a strdup() that can't return NULL */ #define STRDUP(str)\ ut_strdup(__FILE__, __LINE__, __func__, str) /* a malloc() that only returns page aligned memory */ #define PAGEALIGNMALLOC(size)\ ut_pagealignmalloc(__FILE__, __LINE__, __func__, size) /* a malloc() that returns memory with given alignment */ #define MEMALIGN(alignment, size)\ ut_memalign(__FILE__, __LINE__, __func__, alignment, size) /* * A mmap() that returns anonymous memory with given alignment and guard * pages. */ #define MMAP_ANON_ALIGNED(size, alignment)\ ut_mmap_anon_aligned(__FILE__, __LINE__, __func__, alignment, size) #define MUNMAP_ANON_ALIGNED(start, size)\ ut_munmap_anon_aligned(__FILE__, __LINE__, __func__, start, size) /* * file operations */ int ut_open(const char *file, int line, const char *func, const char *path, int flags, ...); int ut_wopen(const char *file, int line, const char *func, const wchar_t *path, int flags, ...); int ut_close(const char *file, int line, const char *func, int fd); FILE *ut_fopen(const char *file, int line, const char *func, const char *path, const char *mode); int ut_fclose(const char *file, int line, const char *func, FILE *stream); int ut_unlink(const char *file, int line, const char *func, const char *path); size_t ut_write(const char *file, int line, const char *func, int fd, const void *buf, size_t len); size_t ut_read(const char *file, int line, const char *func, int fd, void *buf, size_t len); os_off_t ut_lseek(const char *file, int line, const char *func, int fd, os_off_t offset, int whence); int ut_posix_fallocate(const char *file, int line, const char *func, int fd, os_off_t offset, os_off_t len); int ut_stat(const char *file, int line, const char *func, const char *path, os_stat_t *st_bufp); int ut_statW(const char *file, int line, const char *func, const wchar_t *path, os_stat_t *st_bufp); int ut_fstat(const char *file, int line, const char *func, int fd, os_stat_t *st_bufp); void *ut_mmap(const char *file, int line, const char *func, void *addr, size_t length, int prot, int flags, int fd, os_off_t offset); int ut_munmap(const char *file, int line, const char *func, void *addr, size_t length); int ut_mprotect(const char *file, int line, const char *func, void *addr, size_t len, int prot); int ut_ftruncate(const char *file, int line, const char *func, int fd, os_off_t length); long long ut_strtoll(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); long ut_strtol(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); int ut_strtoi(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); unsigned long long ut_strtoull(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); unsigned long ut_strtoul(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); unsigned ut_strtou(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); int ut_snprintf(const char *file, int line, const char *func, char *str, size_t size, const char *format, ...); /* an open() that can't return < 0 */ #define OPEN(path, ...)\ ut_open(__FILE__, __LINE__, __func__, path, __VA_ARGS__) /* a _wopen() that can't return < 0 */ #define WOPEN(path, ...)\ ut_wopen(__FILE__, __LINE__, __func__, path, __VA_ARGS__) /* a close() that can't return -1 */ #define CLOSE(fd)\ ut_close(__FILE__, __LINE__, __func__, fd) /* an fopen() that can't return != 0 */ #define FOPEN(path, mode)\ ut_fopen(__FILE__, __LINE__, __func__, path, mode) /* a fclose() that can't return != 0 */ #define FCLOSE(stream)\ ut_fclose(__FILE__, __LINE__, __func__, stream) /* an unlink() that can't return -1 */ #define UNLINK(path)\ ut_unlink(__FILE__, __LINE__, __func__, path) /* a write() that can't return -1 */ #define WRITE(fd, buf, len)\ ut_write(__FILE__, __LINE__, __func__, fd, buf, len) /* a read() that can't return -1 */ #define READ(fd, buf, len)\ ut_read(__FILE__, __LINE__, __func__, fd, buf, len) /* a lseek() that can't return -1 */ #define LSEEK(fd, offset, whence)\ ut_lseek(__FILE__, __LINE__, __func__, fd, offset, whence) #define POSIX_FALLOCATE(fd, off, len)\ ut_posix_fallocate(__FILE__, __LINE__, __func__, fd, off, len) #define FSTAT(fd, st_bufp)\ ut_fstat(__FILE__, __LINE__, __func__, fd, st_bufp) /* a mmap() that can't return MAP_FAILED */ #define MMAP(addr, len, prot, flags, fd, offset)\ ut_mmap(__FILE__, __LINE__, __func__, addr, len, prot, flags, fd, offset); /* a munmap() that can't return -1 */ #define MUNMAP(addr, length)\ ut_munmap(__FILE__, __LINE__, __func__, addr, length); /* a mprotect() that can't return -1 */ #define MPROTECT(addr, len, prot)\ ut_mprotect(__FILE__, __LINE__, __func__, addr, len, prot); #define STAT(path, st_bufp)\ ut_stat(__FILE__, __LINE__, __func__, path, st_bufp) #define STATW(path, st_bufp)\ ut_statW(__FILE__, __LINE__, __func__, path, st_bufp) #define FTRUNCATE(fd, length)\ ut_ftruncate(__FILE__, __LINE__, __func__, fd, length) #define ATOU(nptr) STRTOU(nptr, NULL, 10) #define ATOUL(nptr) STRTOUL(nptr, NULL, 10) #define ATOULL(nptr) STRTOULL(nptr, NULL, 10) #define ATOI(nptr) STRTOI(nptr, NULL, 10) #define ATOL(nptr) STRTOL(nptr, NULL, 10) #define ATOLL(nptr) STRTOLL(nptr, NULL, 10) #define STRTOULL(nptr, endptr, base)\ ut_strtoull(__FILE__, __LINE__, __func__, nptr, endptr, base) #define STRTOUL(nptr, endptr, base)\ ut_strtoul(__FILE__, __LINE__, __func__, nptr, endptr, base) #define STRTOL(nptr, endptr, base)\ ut_strtol(__FILE__, __LINE__, __func__, nptr, endptr, base) #define STRTOLL(nptr, endptr, base)\ ut_strtoll(__FILE__, __LINE__, __func__, nptr, endptr, base) #define STRTOU(nptr, endptr, base)\ ut_strtou(__FILE__, __LINE__, __func__, nptr, endptr, base) #define STRTOI(nptr, endptr, base)\ ut_strtoi(__FILE__, __LINE__, __func__, nptr, endptr, base) #define SNPRINTF(str, size, format, ...) \ ut_snprintf(__FILE__, __LINE__, __func__, \ str, size, format, __VA_ARGS__) #ifndef _WIN32 #define ut_jmp_buf_t sigjmp_buf #define ut_siglongjmp(b) siglongjmp(b, 1) #define ut_sigsetjmp(b) sigsetjmp(b, 1) #else #define ut_jmp_buf_t jmp_buf #define ut_siglongjmp(b) longjmp(b, 1) #define ut_sigsetjmp(b) setjmp(b) #endif void ut_suppress_errmsg(void); void ut_unsuppress_errmsg(void); void ut_suppress_crt_assert(void); void ut_unsuppress_crt_assert(void); /* * signals... */ int ut_sigaction(const char *file, int line, const char *func, int signum, struct sigaction *act, struct sigaction *oldact); /* a sigaction() that can't return an error */ #define SIGACTION(signum, act, oldact)\ ut_sigaction(__FILE__, __LINE__, __func__, signum, act, oldact) /* * pthreads... */ int ut_thread_create(const char *file, int line, const char *func, os_thread_t *__restrict thread, const os_thread_attr_t *__restrict attr, void *(*start_routine)(void *), void *__restrict arg); int ut_thread_join(const char *file, int line, const char *func, os_thread_t *thread, void **value_ptr); /* a os_thread_create() that can't return an error */ #define THREAD_CREATE(thread, attr, start_routine, arg)\ ut_thread_create(__FILE__, __LINE__, __func__,\ thread, attr, start_routine, arg) /* a os_thread_join() that can't return an error */ #define THREAD_JOIN(thread, value_ptr)\ ut_thread_join(__FILE__, __LINE__, __func__, thread, value_ptr) /* * processes... */ #ifdef _WIN32 intptr_t ut_spawnv(int argc, const char **argv, ...); #endif /* * mocks... * * NOTE: On Linux, function mocking is implemented using wrapper functions. * See "--wrap" option of the GNU linker. * There is no such feature in VC++, so on Windows we do the mocking at * compile time, by redefining symbol names: * - all the references to <symbol> are replaced with <__wrap_symbol> * in all the compilation units, except the one where the <symbol> is * defined and the test source file * - the original definition of <symbol> is replaced with <__real_symbol> * - a wrapper function <__wrap_symbol> must be defined in the test program * (it may still call the original function via <__real_symbol>) * Such solution seems to be sufficient for the purpose of our tests, even * though it has some limitations. I.e. it does no work well with malloc/free, * so to wrap the system memory allocator functions, we use the built-in * feature of all the PMDK libraries, allowing to override default memory * allocator with the custom one. */ #ifndef _WIN32 #define _FUNC_REAL_DECL(name, ret_type, ...)\ ret_type __real_##name(__VA_ARGS__) __attribute__((unused)); #else #define _FUNC_REAL_DECL(name, ret_type, ...)\ ret_type name(__VA_ARGS__); #endif #ifndef _WIN32 #define _FUNC_REAL(name)\ __real_##name #else #define _FUNC_REAL(name)\ name #endif #define RCOUNTER(name)\ _rcounter##name #define FUNC_MOCK_RCOUNTER_SET(name, val)\ RCOUNTER(name) = val; #define FUNC_MOCK(name, ret_type, ...)\ _FUNC_REAL_DECL(name, ret_type, ##__VA_ARGS__)\ static unsigned RCOUNTER(name);\ ret_type __wrap_##name(__VA_ARGS__);\ ret_type __wrap_##name(__VA_ARGS__) {\ switch (util_fetch_and_add32(&RCOUNTER(name), 1)) { #define FUNC_MOCK_DLLIMPORT(name, ret_type, ...)\ __declspec(dllimport) _FUNC_REAL_DECL(name, ret_type, ##__VA_ARGS__)\ static unsigned RCOUNTER(name);\ ret_type __wrap_##name(__VA_ARGS__);\ ret_type __wrap_##name(__VA_ARGS__) {\ switch (util_fetch_and_add32(&RCOUNTER(name), 1)) { #define FUNC_MOCK_END\ }} #define FUNC_MOCK_RUN(run)\ case run: #define FUNC_MOCK_RUN_DEFAULT\ default: #define FUNC_MOCK_RUN_RET(run, ret)\ case run: return (ret); #define FUNC_MOCK_RUN_RET_DEFAULT_REAL(name, ...)\ default: return _FUNC_REAL(name)(__VA_ARGS__); #define FUNC_MOCK_RUN_RET_DEFAULT(ret)\ default: return (ret); #define FUNC_MOCK_RET_ALWAYS(name, ret_type, ret, ...)\ FUNC_MOCK(name, ret_type, __VA_ARGS__)\ FUNC_MOCK_RUN_RET_DEFAULT(ret);\ FUNC_MOCK_END #define FUNC_MOCK_RET_ALWAYS_VOID(name, ...)\ FUNC_MOCK(name, void, __VA_ARGS__)\ default: return;\ FUNC_MOCK_END extern unsigned long Ut_pagesize; extern unsigned long long Ut_mmap_align; extern os_mutex_t Sigactions_lock; void ut_dump_backtrace(void); void ut_sighandler(int); void ut_register_sighandlers(void); uint16_t ut_checksum(uint8_t *addr, size_t len); char *ut_toUTF8(const wchar_t *wstr); wchar_t *ut_toUTF16(const char *wstr); struct test_case { const char *name; int (*func)(const struct test_case *tc, int argc, char *argv[]); }; /* * get_tc -- return test case of specified name */ static inline const struct test_case * get_tc(const char *name, const struct test_case *test_cases, size_t ntests) { for (size_t i = 0; i < ntests; i++) { if (strcmp(name, test_cases[i].name) == 0) return &test_cases[i]; } return NULL; } static inline void TEST_CASE_PROCESS(int argc, char *argv[], const struct test_case *test_cases, size_t ntests) { if (argc < 2) UT_FATAL("usage: %s <test case> [<args>]", argv[0]); for (int i = 1; i < argc; i++) { char *str_test = argv[i]; const int args_off = i + 1; const struct test_case *tc = get_tc(str_test, test_cases, ntests); if (!tc) UT_FATAL("unknown test case -- '%s'", str_test); int ret = tc->func(tc, argc - args_off, &argv[args_off]); if (ret < 0) UT_FATAL("test return value cannot be negative"); i += ret; } } #define TEST_CASE_DECLARE(_name)\ int \ _name(const struct test_case *tc, int argc, char *argv[]) #define TEST_CASE(_name)\ {\ .name = #_name,\ .func = (_name),\ } #define STR(x) #x #define ASSERT_ALIGNED_BEGIN(type) do {\ size_t off = 0;\ const char *last = "(none)";\ type t; #define ASSERT_ALIGNED_FIELD(type, field) do {\ if (offsetof(type, field) != off)\ UT_FATAL("%s: padding, missing field or fields not in order between "\ "'%s' and '%s' -- offset %lu, real offset %lu",\ STR(type), last, STR(field), off, offsetof(type, field));\ off += sizeof(t.field);\ last = STR(field);\ } while (0) #define ASSERT_FIELD_SIZE(field, size) do {\ UT_COMPILE_ERROR_ON(size != sizeof(t.field));\ } while (0) #define ASSERT_OFFSET_CHECKPOINT(type, checkpoint) do {\ if (off != checkpoint)\ UT_FATAL("%s: violated offset checkpoint -- "\ "checkpoint %lu, real offset %lu",\ STR(type), checkpoint, off);\ } while (0) #define ASSERT_ALIGNED_CHECK(type)\ if (off != sizeof(type))\ UT_FATAL("%s: missing field or padding after '%s': "\ "sizeof(%s) = %lu, fields size = %lu",\ STR(type), last, STR(type), sizeof(type), off);\ } while (0) /* * AddressSanitizer */ #ifdef __clang__ #if __has_feature(address_sanitizer) #define UT_DEFINE_ASAN_POISON #endif #else #ifdef __SANITIZE_ADDRESS__ #define UT_DEFINE_ASAN_POISON #endif #endif #ifdef UT_DEFINE_ASAN_POISON void __asan_poison_memory_region(void const volatile *addr, size_t size); void __asan_unpoison_memory_region(void const volatile *addr, size_t size); #define ASAN_POISON_MEMORY_REGION(addr, size) \ __asan_poison_memory_region((addr), (size)) #define ASAN_UNPOISON_MEMORY_REGION(addr, size) \ __asan_unpoison_memory_region((addr), (size)) #else #define ASAN_POISON_MEMORY_REGION(addr, size) \ ((void)(addr), (void)(size)) #define ASAN_UNPOISON_MEMORY_REGION(addr, size) \ ((void)(addr), (void)(size)) #endif #ifdef __cplusplus } #endif #endif /* unittest.h */
23,907
29.769627
79
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/unittest/ut_pmem2.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2019-2020, Intel Corporation */ /* * ut_pmem2.h -- utility helper functions for libpmem tests */ #ifndef UT_PMEM2_H #define UT_PMEM2_H 1 #include "ut_pmem2_config.h" #include "ut_pmem2_map.h" #include "ut_pmem2_source.h" #include "ut_pmem2_utils.h" #endif /* UT_PMEM2_H */
333
18.647059
59
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/unittest/ut_pmem2_config.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2019-2020, Intel Corporation */ /* * ut_pmem2_config.h -- utility helper functions for libpmem2 config tests */ #ifndef UT_PMEM2_CONFIG_H #define UT_PMEM2_CONFIG_H 1 #include "ut_fh.h" /* a pmem2_config_new() that can't return NULL */ #define PMEM2_CONFIG_NEW(cfg) \ ut_pmem2_config_new(__FILE__, __LINE__, __func__, cfg) /* a pmem2_config_set_required_store_granularity() doesn't return an error */ #define PMEM2_CONFIG_SET_GRANULARITY(cfg, g) \ ut_pmem2_config_set_required_store_granularity \ (__FILE__, __LINE__, __func__, cfg, g) /* a pmem2_config_delete() that can't return NULL */ #define PMEM2_CONFIG_DELETE(cfg) \ ut_pmem2_config_delete(__FILE__, __LINE__, __func__, cfg) void ut_pmem2_config_new(const char *file, int line, const char *func, struct pmem2_config **cfg); void ut_pmem2_config_set_required_store_granularity(const char *file, int line, const char *func, struct pmem2_config *cfg, enum pmem2_granularity g); void ut_pmem2_config_delete(const char *file, int line, const char *func, struct pmem2_config **cfg); #endif /* UT_PMEM2_CONFIG_H */
1,152
30.162162
77
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/unittest/ut_pmem2_utils.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2019, Intel Corporation */ /* * ut_pmem2_utils.h -- utility helper functions for libpmem2 tests */ #ifndef UT_PMEM2_UTILS_H #define UT_PMEM2_UTILS_H 1 /* veryfies error code and prints appropriate error message in case of error */ #define UT_PMEM2_EXPECT_RETURN(value, expected) \ ut_pmem2_expect_return(__FILE__, __LINE__, __func__, \ value, expected) void ut_pmem2_expect_return(const char *file, int line, const char *func, int value, int expected); #endif /* UT_PMEM2_UTILS_H */
552
26.65
79
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/unittest/ut_fh.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2019-2020, Intel Corporation */ /* * ut_fh.h -- OS-independent file handle / file descriptor interface */ #ifndef UT_FH_H #define UT_FH_H #include "os.h" struct FHandle; enum file_handle_type { FH_FD, FH_HANDLE }; #define FH_ACCMODE (7) #define FH_READ (1 << 0) #define FH_WRITE (1 << 1) #define FH_RDWR (FH_READ | FH_WRITE) #define FH_EXEC (1 << 2) #define FH_CREAT (1 << 3) #define FH_EXCL (1 << 4) #define FH_TRUNC (1 << 5) /* needs directory, on Windows it creates publicly visible file */ #define FH_TMPFILE (1 << 6) #define FH_DIRECTORY (1 << 7) #define UT_FH_OPEN(type, path, flags, ...) \ ut_fh_open(__FILE__, __LINE__, __func__, type, path, \ flags, ##__VA_ARGS__) #define UT_FH_TRUNCATE(fhandle, size) \ ut_fh_truncate(__FILE__, __LINE__, __func__, fhandle, size) #define UT_FH_GET_FD(fhandle) \ ut_fh_get_fd(__FILE__, __LINE__, __func__, fhandle) #ifdef _WIN32 #define UT_FH_GET_HANDLE(fhandle) \ ut_fh_get_handle(__FILE__, __LINE__, __func__, fhandle) #endif #define UT_FH_CLOSE(fhandle) \ ut_fh_close(__FILE__, __LINE__, __func__, fhandle) struct FHandle *ut_fh_open(const char *file, int line, const char *func, enum file_handle_type type, const char *path, int flags, ...); void ut_fh_truncate(const char *file, int line, const char *func, struct FHandle *f, os_off_t length); void ut_fh_close(const char *file, int line, const char *func, struct FHandle *f); enum file_handle_type ut_fh_get_handle_type(struct FHandle *fh); int ut_fh_get_fd(const char *file, int line, const char *func, struct FHandle *f); #ifdef _WIN32 HANDLE ut_fh_get_handle(const char *file, int line, const char *func, struct FHandle *f); #endif #endif
1,761
24.536232
72
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/unittest/ut_pmem2_map.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2020, Intel Corporation */ /* * ut_pmem2_map.h -- utility helper functions for libpmem2 map tests */ #ifndef UT_PMEM2_MAP_H #define UT_PMEM2_MAP_H 1 /* a pmem2_map() that can't return NULL */ #define PMEM2_MAP(cfg, src, map) \ ut_pmem2_map(__FILE__, __LINE__, __func__, cfg, src, map) void ut_pmem2_map(const char *file, int line, const char *func, struct pmem2_config *cfg, struct pmem2_source *src, struct pmem2_map **map); #endif /* UT_PMEM2_MAP_H */
522
25.15
68
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/unittest/ut_pmem2_source.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2020, Intel Corporation */ /* * ut_pmem2_source.h -- utility helper functions for libpmem2 source tests */ #ifndef UT_PMEM2_SOURCE_H #define UT_PMEM2_SOURCE_H 1 #include "ut_fh.h" /* a pmem2_config_set_fd() that can't return NULL */ #define PMEM2_SOURCE_FROM_FD(src, fd) \ ut_pmem2_source_from_fd(__FILE__, __LINE__, __func__, src, fd) /* a pmem2_config_set_fd() that can't return NULL */ #define PMEM2_SOURCE_FROM_FH(src, fh) \ ut_pmem2_source_from_fh(__FILE__, __LINE__, __func__, src, fh) /* a pmem2_source_alignment() that can't return an error */ #define PMEM2_SOURCE_ALIGNMENT(src, al) \ ut_pmem2_source_alignment(__FILE__, __LINE__, __func__, src, al) /* a pmem2_source_delete() that can't return NULL */ #define PMEM2_SOURCE_DELETE(src) \ ut_pmem2_source_delete(__FILE__, __LINE__, __func__, src) /* a pmem2_source_source() that can't return NULL */ #define PMEM2_SOURCE_SIZE(src, size) \ ut_pmem2_source_size(__FILE__, __LINE__, __func__, src, size) void ut_pmem2_source_from_fd(const char *file, int line, const char *func, struct pmem2_source **src, int fd); void ut_pmem2_source_from_fh(const char *file, int line, const char *func, struct pmem2_source **src, struct FHandle *fhandle); void ut_pmem2_source_alignment(const char *file, int line, const char *func, struct pmem2_source *src, size_t *alignment); void ut_pmem2_source_delete(const char *file, int line, const char *func, struct pmem2_source **src); void ut_pmem2_source_size(const char *file, int line, const char *func, struct pmem2_source *src, size_t *size); #endif /* UT_PMEM2_SOURCE_H */
1,667
33.040816
76
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/unittest/ut_pmem2_setup.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2020, Intel Corporation */ /* * ut_pmem2_setup.h -- libpmem2 setup functions using non-public API * (only for unit tests) */ #ifndef UT_PMEM2_SETUP_H #define UT_PMEM2_SETUP_H 1 #include "ut_fh.h" void ut_pmem2_prepare_config(struct pmem2_config *cfg, struct pmem2_source **src, struct FHandle **fh, enum file_handle_type fh_type, const char *path, size_t length, size_t offset, int access); #endif /* UT_PMEM2_SETUP_H */
486
23.35
68
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/unittest/unittest.sh
# # SPDX-License-Identifier: BSD-3-Clause # Copyright 2014-2020, Intel Corporation # # Copyright (c) 2016, Microsoft Corporation. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # set -e # make sure we have a well defined locale for string operations here export LC_ALL="C" #export LC_ALL="en_US.UTF-8" if ! [ -f ../envconfig.sh ]; then echo >&2 "envconfig.sh is missing -- is the tree built?" exit 1 fi . ../testconfig.sh . ../envconfig.sh if [ -t 1 ]; then IS_TERMINAL_STDOUT=YES fi if [ -t 2 ]; then IS_TERMINAL_STDERR=YES fi function is_terminal() { local fd fd=$1 case $(eval "echo \${IS_TERMINAL_${fd}}") in YES) : ;; *) false ;; esac } function interactive_color() { local color fd color=$1 fd=$2 shift 2 if is_terminal ${fd} && command -v tput >/dev/null; then echo "$(tput setaf $color || :)$*$(tput sgr0 || :)" else echo "$*" fi } function interactive_red() { interactive_color 1 "$@" } function interactive_green() { interactive_color 2 "$@" } function verbose_msg() { if [ "$UNITTEST_LOG_LEVEL" -ge 2 ]; then echo "$*" fi } function msg() { if [ "$UNITTEST_LOG_LEVEL" -ge 1 ]; then echo "$*" fi } function fatal() { echo "$*" >&2 exit 1 } if [ -z "${UNITTEST_NAME}" ]; then CURDIR=$(basename $(pwd)) SCRIPTNAME=$(basename $0) export UNITTEST_NAME=$CURDIR/$SCRIPTNAME export UNITTEST_NUM=$(echo $SCRIPTNAME | sed "s/TEST//") fi # defaults [ "$UNITTEST_LOG_LEVEL" ] || UNITTEST_LOG_LEVEL=2 [ "$GREP" ] || GREP="grep -a" [ "$TEST" ] || TEST=check [ "$FS" ] || FS=any [ "$BUILD" ] || BUILD=debug [ "$CHECK_TYPE" ] || CHECK_TYPE=auto [ "$CHECK_POOL" ] || CHECK_POOL=0 [ "$VERBOSE" ] || VERBOSE=0 [ -n "${SUFFIX+x}" ] || SUFFIX="😘⠏⠍⠙⠅ɗPMDKӜ⥺🙋" export UNITTEST_LOG_LEVEL GREP TEST FS BUILD CHECK_TYPE CHECK_POOL VERBOSE SUFFIX TOOLS=../tools LIB_TOOLS="../../tools" # Paths to some useful tools [ "$PMEMPOOL" ] || PMEMPOOL=$LIB_TOOLS/pmempool/pmempool [ "$DAXIO" ] || DAXIO=$LIB_TOOLS/daxio/daxio [ "$PMEMSPOIL" ] || PMEMSPOIL=$TOOLS/pmemspoil/pmemspoil.static-nondebug [ "$BTTCREATE" ] || BTTCREATE=$TOOLS/bttcreate/bttcreate.static-nondebug [ "$PMEMWRITE" ] || PMEMWRITE=$TOOLS/pmemwrite/pmemwrite [ "$PMEMALLOC" ] || PMEMALLOC=$TOOLS/pmemalloc/pmemalloc [ "$PMEMOBJCLI" ] || PMEMOBJCLI=$TOOLS/pmemobjcli/pmemobjcli [ "$PMEMDETECT" ] || PMEMDETECT=$TOOLS/pmemdetect/pmemdetect.static-nondebug [ "$PMREORDER" ] || PMREORDER=$LIB_TOOLS/pmreorder/pmreorder.py [ "$FIP" ] || FIP=$TOOLS/fip/fip [ "$DDMAP" ] || DDMAP=$TOOLS/ddmap/ddmap [ "$CMPMAP" ] || CMPMAP=$TOOLS/cmpmap/cmpmap [ "$EXTENTS" ] || EXTENTS=$TOOLS/extents/extents [ "$FALLOCATE_DETECT" ] || FALLOCATE_DETECT=$TOOLS/fallocate_detect/fallocate_detect.static-nondebug [ "$OBJ_VERIFY" ] || OBJ_VERIFY=$TOOLS/obj_verify/obj_verify [ "$USC_PERMISSION" ] || USC_PERMISSION=$TOOLS/usc_permission_check/usc_permission_check.static-nondebug [ "$ANONYMOUS_MMAP" ] || ANONYMOUS_MMAP=$TOOLS/anonymous_mmap/anonymous_mmap.static-nondebug # force globs to fail if they don't match shopt -s failglob # number of remote nodes required in the current unit test NODES_MAX=-1 # sizes of alignments SIZE_4KB=4096 SIZE_2MB=2097152 readonly PAGE_SIZE=$(getconf PAGESIZE) # PMEMOBJ limitations PMEMOBJ_MAX_ALLOC_SIZE=17177771968 # SSH and SCP options SSH_OPTS="-o BatchMode=yes" SCP_OPTS="-o BatchMode=yes -r -p" NDCTL_MIN_VERSION="63" # list of common files to be copied to all remote nodes DIR_SRC="../.." FILES_COMMON_DIR="\ $DIR_SRC/test/*.supp \ $DIR_SRC/tools/rpmemd/rpmemd \ $DIR_SRC/tools/pmempool/pmempool \ $DIR_SRC/test/tools/extents/extents \ $DIR_SRC/test/tools/obj_verify/obj_verify \ $DIR_SRC/test/tools/ctrld/ctrld \ $DIR_SRC/test/tools/fip/fip" # Portability VALGRIND_SUPP="--suppressions=../ld.supp \ --suppressions=../memcheck-libunwind.supp \ --suppressions=../memcheck-ndctl.supp" if [ "$(uname -s)" = "FreeBSD" ]; then DATE="gdate" DD="gdd" FALLOCATE="mkfile" VM_OVERCOMMIT="[ $(sysctl vm.overcommit | awk '{print $2}') == 0 ]" RM_ONEFS="-x" STAT_MODE="-f%Lp" STAT_PERM="-f%Sp" STAT_SIZE="-f%z" STRACE="truss" VALGRIND_SUPP="$VALGRIND_SUPP --suppressions=../freebsd.supp" else DATE="date" DD="dd" FALLOCATE="fallocate -l" VM_OVERCOMMIT="[ $(cat /proc/sys/vm/overcommit_memory) != 2 ]" RM_ONEFS="--one-file-system" STAT_MODE="-c%a" STAT_PERM="-c%A" STAT_SIZE="-c%s" STRACE="strace" fi # array of lists of PID files to be cleaned in case of an error NODE_PID_FILES[0]="" case "$BUILD" in debug|static-debug) if [ -z "$PMDK_LIB_PATH_DEBUG" ]; then PMDK_LIB_PATH=../../debug REMOTE_PMDK_LIB_PATH=../debug else PMDK_LIB_PATH=$PMDK_LIB_PATH_DEBUG REMOTE_PMDK_LIB_PATH=$PMDK_LIB_PATH_DEBUG fi ;; nondebug|static-nondebug) if [ -z "$PMDK_LIB_PATH_NONDEBUG" ]; then PMDK_LIB_PATH=../../nondebug REMOTE_PMDK_LIB_PATH=../nondebug else PMDK_LIB_PATH=$PMDK_LIB_PATH_NONDEBUG REMOTE_PMDK_LIB_PATH=$PMDK_LIB_PATH_NONDEBUG fi ;; esac export LD_LIBRARY_PATH=$PMDK_LIB_PATH:$GLOBAL_LIB_PATH:$LD_LIBRARY_PATH export REMOTE_LD_LIBRARY_PATH=$REMOTE_PMDK_LIB_PATH:$GLOBAL_LIB_PATH:\$LD_LIBRARY_PATH export PATH=$GLOBAL_PATH:$PATH export REMOTE_PATH=$GLOBAL_PATH:\$PATH export PKG_CONFIG_PATH=$GLOBAL_PKG_CONFIG_PATH:$PKG_CONFIG_PATH export REMOTE_PKG_CONFIG_PATH=$GLOBAL_PKG_CONFIG_PATH:\$PKG_CONFIG_PATH # # When running static binary tests, append the build type to the binary # case "$BUILD" in static-*) EXESUFFIX=.$BUILD ;; esac # # The variable DIR is constructed so the test uses that directory when # constructing test files. DIR is chosen based on the fs-type for # this test, and if the appropriate fs-type doesn't have a directory # defined in testconfig.sh, the test is skipped. # # This behavior can be overridden by setting DIR. For example: # DIR=/force/test/dir ./TEST0 # curtestdir=`basename $PWD` # just in case if [ ! "$curtestdir" ]; then fatal "curtestdir does not have a value" fi curtestdir=test_$curtestdir if [ ! "$UNITTEST_NUM" ]; then fatal "UNITTEST_NUM does not have a value" fi if [ ! "$UNITTEST_NAME" ]; then fatal "UNITTEST_NAME does not have a value" fi REAL_FS=$FS if [ "$DIR" ]; then DIR=$DIR/$curtestdir$UNITTEST_NUM else case "$FS" in pmem) # if a variable is set - it must point to a valid directory if [ "$PMEM_FS_DIR" == "" ]; then fatal "$UNITTEST_NAME: PMEM_FS_DIR is not set" fi DIR=$PMEM_FS_DIR/$DIRSUFFIX/$curtestdir$UNITTEST_NUM if [ "$PMEM_FS_DIR_FORCE_PMEM" = "1" ] || [ "$PMEM_FS_DIR_FORCE_PMEM" = "2" ]; then export PMEM_IS_PMEM_FORCE=1 fi ;; non-pmem) # if a variable is set - it must point to a valid directory if [ "$NON_PMEM_FS_DIR" == "" ]; then fatal "$UNITTEST_NAME: NON_PMEM_FS_DIR is not set" fi DIR=$NON_PMEM_FS_DIR/$DIRSUFFIX/$curtestdir$UNITTEST_NUM ;; any) if [ "$PMEM_FS_DIR" != "" ]; then DIR=$PMEM_FS_DIR/$DIRSUFFIX/$curtestdir$UNITTEST_NUM REAL_FS=pmem if [ "$PMEM_FS_DIR_FORCE_PMEM" = "1" ] || [ "$PMEM_FS_DIR_FORCE_PMEM" = "2" ]; then export PMEM_IS_PMEM_FORCE=1 fi elif [ "$NON_PMEM_FS_DIR" != "" ]; then DIR=$NON_PMEM_FS_DIR/$DIRSUFFIX/$curtestdir$UNITTEST_NUM REAL_FS=non-pmem else fatal "$UNITTEST_NAME: fs-type=any and both env vars are empty" fi ;; none) DIR=/dev/null/not_existing_dir/$DIRSUFFIX/$curtestdir$UNITTEST_NUM ;; *) verbose_msg "$UNITTEST_NAME: SKIP fs-type $FS (not configured)" exit 0 ;; esac fi # # The default is to turn on library logging to level 3 and save it to local files. # Tests that don't want it on, should override these environment variables. # export PMEM_LOG_LEVEL=3 export PMEM_LOG_FILE=pmem$UNITTEST_NUM.log export PMEMBLK_LOG_LEVEL=3 export PMEMBLK_LOG_FILE=pmemblk$UNITTEST_NUM.log export PMEMLOG_LOG_LEVEL=3 export PMEMLOG_LOG_FILE=pmemlog$UNITTEST_NUM.log export PMEMOBJ_LOG_LEVEL=3 export PMEMOBJ_LOG_FILE=pmemobj$UNITTEST_NUM.log export PMEMPOOL_LOG_LEVEL=3 export PMEMPOOL_LOG_FILE=pmempool$UNITTEST_NUM.log export PMREORDER_LOG_FILE=pmreorder$UNITTEST_NUM.log export OUT_LOG_FILE=out$UNITTEST_NUM.log export ERR_LOG_FILE=err$UNITTEST_NUM.log export TRACE_LOG_FILE=trace$UNITTEST_NUM.log export PREP_LOG_FILE=prep$UNITTEST_NUM.log export VALGRIND_LOG_FILE=${CHECK_TYPE}${UNITTEST_NUM}.log export VALIDATE_VALGRIND_LOG=1 export RPMEM_LOG_LEVEL=3 export RPMEM_LOG_FILE=rpmem$UNITTEST_NUM.log export RPMEMD_LOG_LEVEL=info export RPMEMD_LOG_FILE=rpmemd$UNITTEST_NUM.log export REMOTE_VARS=" RPMEMD_LOG_FILE RPMEMD_LOG_LEVEL RPMEM_LOG_FILE RPMEM_LOG_LEVEL PMEM_LOG_FILE PMEM_LOG_LEVEL PMEMOBJ_LOG_FILE PMEMOBJ_LOG_LEVEL PMEMPOOL_LOG_FILE PMEMPOOL_LOG_LEVEL" [ "$UT_DUMP_LINES" ] || UT_DUMP_LINES=30 export CHECK_POOL_LOG_FILE=check_pool_${BUILD}_${UNITTEST_NUM}.log # In case a lock is required for Device DAXes DEVDAX_LOCK=../devdax.lock # # store_exit_on_error -- store on a stack a sign that reflects the current state # of the 'errexit' shell option # function store_exit_on_error() { if [ "${-#*e}" != "$-" ]; then estack+=- else estack+=+ fi } # # restore_exit_on_error -- restore the state of the 'errexit' shell option # function restore_exit_on_error() { if [ -z $estack ]; then fatal "error: store_exit_on_error function has to be called first" fi eval "set ${estack:${#estack}-1:1}e" estack=${estack%?} } # # disable_exit_on_error -- store the state of the 'errexit' shell option and # disable it # function disable_exit_on_error() { store_exit_on_error set +e } # # get_files -- print list of files in the current directory matching the given regex to stdout # # This function has been implemented to workaround a race condition in # `find`, which fails if any file disappears in the middle of the operation. # # example, to list all *.log files in the current directory # get_files ".*\.log" function get_files() { disable_exit_on_error ls -1 | grep -E "^$*$" restore_exit_on_error } # # get_executables -- print list of executable files in the current directory to stdout # # This function has been implemented to workaround a race condition in # `find`, which fails if any file disappears in the middle of the operation. # function get_executables() { disable_exit_on_error for c in * do if [ -f $c -a -x $c ] then echo "$c" fi done restore_exit_on_error } # # convert_to_bytes -- converts the string with K, M, G or T suffixes # to bytes # # example: # "1G" --> "1073741824" # "2T" --> "2199023255552" # "3k" --> "3072" # "1K" --> "1024" # "10" --> "10" # function convert_to_bytes() { size="$(echo $1 | tr '[:upper:]' '[:lower:]')" if [[ $size == *kib ]] then size=$(($(echo $size | tr -d 'kib') * 1024)) elif [[ $size == *mib ]] then size=$(($(echo $size | tr -d 'mib') * 1024 * 1024)) elif [[ $size == *gib ]] then size=$(($(echo $size | tr -d 'gib') * 1024 * 1024 * 1024)) elif [[ $size == *tib ]] then size=$(($(echo $size | tr -d 'tib') * 1024 * 1024 * 1024 * 1024)) elif [[ $size == *pib ]] then size=$(($(echo $size | tr -d 'pib') * 1024 * 1024 * 1024 * 1024 * 1024)) elif [[ $size == *kb ]] then size=$(($(echo $size | tr -d 'kb') * 1000)) elif [[ $size == *mb ]] then size=$(($(echo $size | tr -d 'mb') * 1000 * 1000)) elif [[ $size == *gb ]] then size=$(($(echo $size | tr -d 'gb') * 1000 * 1000 * 1000)) elif [[ $size == *tb ]] then size=$(($(echo $size | tr -d 'tb') * 1000 * 1000 * 1000 * 1000)) elif [[ $size == *pb ]] then size=$(($(echo $size | tr -d 'pb') * 1000 * 1000 * 1000 * 1000 * 1000)) elif [[ $size == *b ]] then size=$(($(echo $size | tr -d 'b'))) elif [[ $size == *k ]] then size=$(($(echo $size | tr -d 'k') * 1024)) elif [[ $size == *m ]] then size=$(($(echo $size | tr -d 'm') * 1024 * 1024)) elif [[ $size == *g ]] then size=$(($(echo $size | tr -d 'g') * 1024 * 1024 * 1024)) elif [[ $size == *t ]] then size=$(($(echo $size | tr -d 't') * 1024 * 1024 * 1024 * 1024)) elif [[ $size == *p ]] then size=$(($(echo $size | tr -d 'p') * 1024 * 1024 * 1024 * 1024 * 1024)) fi echo "$size" } # # create_file -- create zeroed out files of a given length # # example, to create two files, each 1GB in size: # create_file 1G testfile1 testfile2 # function create_file() { size=$(convert_to_bytes $1) shift for file in $* do $DD if=/dev/zero of=$file bs=1M count=$size iflag=count_bytes status=none >> $PREP_LOG_FILE done } # # create_nonzeroed_file -- create non-zeroed files of a given length # # A given first kilobytes of the file is zeroed out. # # example, to create two files, each 1GB in size, with first 4K zeroed # create_nonzeroed_file 1G 4K testfile1 testfile2 # function create_nonzeroed_file() { offset=$(convert_to_bytes $2) size=$(($(convert_to_bytes $1) - $offset)) shift 2 for file in $* do truncate -s ${offset} $file >> $PREP_LOG_FILE $DD if=/dev/zero bs=1K count=${size} iflag=count_bytes 2>>$PREP_LOG_FILE | tr '\0' '\132' >> $file done } # # create_holey_file -- create holey files of a given length # # examples: # create_holey_file 1024k testfile1 testfile2 # create_holey_file 2048M testfile1 testfile2 # create_holey_file 234 testfile1 # create_holey_file 2340b testfile1 # # Input unit size is in bytes with optional suffixes like k, KB, M, etc. # function create_holey_file() { size=$(convert_to_bytes $1) shift for file in $* do truncate -s ${size} $file >> $PREP_LOG_FILE done } # # create_poolset -- create a dummy pool set # # Creates a pool set file using the provided list of part sizes and paths. # Optionally, it also creates the selected part files (zeroed, partially zeroed # or non-zeroed) with requested size and mode. The actual file size may be # different than the part size in the pool set file. # 'r' or 'R' on the list of arguments indicate the beginning of the next # replica set and 'm' or 'M' the beginning of the next remote replica set. # 'o' or 'O' indicates the next argument is a pool set option. # A remote replica requires two parameters: a target node and a pool set # descriptor. # # Each part argument has the following format: # psize:ppath[:cmd[:fsize[:mode]]] # # where: # psize - part size or AUTO (only for DAX device) # ppath - path # cmd - (optional) can be: # x - do nothing (may be skipped if there's no 'fsize', 'mode') # z - create zeroed (holey) file # n - create non-zeroed file # h - create non-zeroed file, but with zeroed header (first page) # d - create directory # fsize - (optional) the actual size of the part file (if 'cmd' is not 'x') # mode - (optional) same format as for 'chmod' command # # Each remote replica argument has the following format: # node:desc # # where: # node - target node # desc - pool set descriptor # # example: # The following command define a pool set consisting of two parts: 16MB # and 32MB, a local replica with only one part of 48MB and a remote replica. # The first part file is not created, the second is zeroed. The only replica # part is non-zeroed. Also, the last file is read-only and its size # does not match the information from pool set file. The last but one line # describes a remote replica. The SINGLEHDR poolset option is set, so only # the first part in each replica contains a pool header. The remote poolset # also has to have the SINGLEHDR option. # # create_poolset ./pool.set 16M:testfile1 32M:testfile2:z \ # R 48M:testfile3:n:11M:0400 \ # M remote_node:remote_pool.set \ # O SINGLEHDR # function create_poolset() { psfile=$1 shift 1 echo "PMEMPOOLSET" > $psfile while [ "$1" ] do if [ "$1" = "M" ] || [ "$1" = "m" ] # remote replica then shift 1 cmd=$1 shift 1 # extract last ":" separated segment as descriptor # extract everything before last ":" as node address # this extraction method is compatible with IPv6 and IPv4 node=${cmd%:*} desc=${cmd##*:} echo "REPLICA $node $desc" >> $psfile continue fi if [ "$1" = "R" ] || [ "$1" = "r" ] then echo "REPLICA" >> $psfile shift 1 continue fi if [ "$1" = "O" ] || [ "$1" = "o" ] then echo "OPTION $2" >> $psfile shift 2 continue fi cmd=$1 fparms=(${cmd//:/ }) shift 1 fsize=${fparms[0]} fpath=${fparms[1]} cmd=${fparms[2]} asize=${fparms[3]} mode=${fparms[4]} if [ ! $asize ]; then asize=$fsize fi if [ "$asize" != "AUTO" ]; then asize=$(convert_to_bytes $asize) fi case "$cmd" in x) # do nothing ;; z) # zeroed (holey) file truncate -s $asize $fpath >> $PREP_LOG_FILE ;; n) # non-zeroed file $DD if=/dev/zero bs=$asize count=1 2>>$PREP_LOG_FILE | tr '\0' '\132' >> $fpath ;; h) # non-zeroed file, except page size header truncate -s $PAGE_SIZE $fpath >> prep$UNITTEST_NUM.log $DD if=/dev/zero bs=$asize count=1 2>>$PREP_LOG_FILE | tr '\0' '\132' >> $fpath truncate -s $asize $fpath >> $PREP_LOG_FILE ;; d) mkdir -p $fpath ;; esac if [ $mode ]; then chmod $mode $fpath fi echo "$fsize $fpath" >> $psfile done } function dump_last_n_lines() { if [ "$1" != "" -a -f "$1" ]; then ln=`wc -l < $1` if [ $ln -gt $UT_DUMP_LINES ]; then echo -e "Last $UT_DUMP_LINES lines of $1 below (whole file has $ln lines)." >&2 ln=$UT_DUMP_LINES else echo -e "$1 below." >&2 fi paste -d " " <(yes $UNITTEST_NAME $1 | head -n $ln) <(tail -n $ln $1) >&2 echo >&2 fi } # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810295 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=780173 # https://bugs.kde.org/show_bug.cgi?id=303877 # # valgrind issues an unsuppressable warning when exceeding # the brk segment, causing matching failures. We can safely # ignore it because malloc() will fallback to mmap() anyway. function valgrind_ignore_warnings() { cat $1 | grep -v \ -e "WARNING: Serious error when reading debug info" \ -e "When reading debug info from " \ -e "Ignoring non-Dwarf2/3/4 block in .debug_info" \ -e "Last block truncated in .debug_info; ignoring" \ -e "parse_CU_Header: is neither DWARF2 nor DWARF3 nor DWARF4" \ -e "brk segment overflow" \ -e "see section Limitations in user manual" \ -e "Warning: set address range perms: large range"\ -e "further instances of this message will not be shown"\ -e "get_Form_contents: DW_FORM_GNU_strp_alt used, but no alternate .debug_str"\ > $1.tmp mv $1.tmp $1 } # # valgrind_ignore_messages -- cuts off Valgrind messages that are irrelevant # to the correctness of the test, but changes during Valgrind rebase # usage: valgrind_ignore_messages <log-file> # function valgrind_ignore_messages() { if [ -e "$1.match" ]; then cat $1 | grep -v \ -e "For lists of detected and suppressed errors, rerun with: -s" \ -e "For counts of detected and suppressed errors, rerun with: -v" \ > $1.tmp mv $1.tmp $1 fi } # # get_trace -- return tracing tool command line if applicable # usage: get_trace <check type> <log file> [<node>] # function get_trace() { if [ "$1" == "none" ]; then echo "$TRACE" return fi local exe=$VALGRINDEXE local check_type=$1 local log_file=$2 local opts="$VALGRIND_OPTS" local node=-1 [ "$#" -eq 3 ] && node=$3 if [ "$check_type" = "memcheck" -a "$MEMCHECK_DONT_CHECK_LEAKS" != "1" ]; then opts="$opts --leak-check=full" fi if [ "$check_type" = "pmemcheck" ]; then # Before Skylake, Intel CPUs did not have clflushopt instruction, so # pmem_flush and pmem_persist both translated to clflush. # This means that missing pmem_drain after pmem_flush could only be # detected on Skylake+ CPUs. # This option tells pmemcheck to expect fence (sfence or # VALGRIND_PMC_DO_FENCE client request, used by pmem_drain) after # clflush and makes pmemcheck output the same on pre-Skylake and # post-Skylake CPUs. opts="$opts --expect-fence-after-clflush=yes" fi opts="$opts $VALGRIND_SUPP" if [ "$node" -ne -1 ]; then exe=${NODE_VALGRINDEXE[$node]} opts="$opts" case "$check_type" in memcheck) opts="$opts --suppressions=../memcheck-libibverbs.supp" ;; helgrind) opts="$opts --suppressions=../helgrind-cxgb4.supp" opts="$opts --suppressions=../helgrind-libfabric.supp" ;; drd) opts="$opts --suppressions=../drd-libfabric.supp" ;; esac fi echo "$exe --tool=$check_type --log-file=$log_file $opts $TRACE" return } # # validate_valgrind_log -- validate valgrind log # usage: validate_valgrind_log <log-file> # function validate_valgrind_log() { [ "$VALIDATE_VALGRIND_LOG" != "1" ] && return # fail if there are valgrind errors found or # if it detects overlapping chunks if [ ! -e "$1.match" ] && grep \ -e "ERROR SUMMARY: [^0]" \ -e "Bad mempool" \ $1 >/dev/null ; then msg=$(interactive_red STDERR "failed") echo -e "$UNITTEST_NAME $msg with Valgrind. See $1. Last 20 lines below." >&2 paste -d " " <(yes $UNITTEST_NAME $1 | head -n 20) <(tail -n 20 $1) >&2 false fi } # # expect_normal_exit -- run a given command, expect it to exit 0 # # if VALGRIND_DISABLED is not empty valgrind tool will be omitted # function expect_normal_exit() { local VALGRIND_LOG_FILE=${CHECK_TYPE}${UNITTEST_NUM}.log local N=$2 # in case of a remote execution disable valgrind check if valgrind is not # enabled on node local _CHECK_TYPE=$CHECK_TYPE if [ "x$VALGRIND_DISABLED" != "x" ]; then _CHECK_TYPE=none fi if [ "$1" == "run_on_node" -o "$1" == "run_on_node_background" ]; then if [ -z $(is_valgrind_enabled_on_node $N) ]; then _CHECK_TYPE="none" fi else N=-1 fi if [ -n "$TRACE" ]; then case "$1" in *_on_node*) msg "$UNITTEST_NAME: SKIP: TRACE is not supported if test is executed on remote nodes" exit 0 esac fi local trace=$(get_trace $_CHECK_TYPE $VALGRIND_LOG_FILE $N) if [ "$MEMCHECK_DONT_CHECK_LEAKS" = "1" -a "$CHECK_TYPE" = "memcheck" ]; then export OLD_ASAN_OPTIONS="${ASAN_OPTIONS}" export ASAN_OPTIONS="detect_leaks=0 ${ASAN_OPTIONS}" fi if [ "$CHECK_TYPE" = "helgrind" ]; then export VALGRIND_OPTS="--suppressions=../helgrind-log.supp" fi if [ "$CHECK_TYPE" = "memcheck" ]; then export VALGRIND_OPTS="$VALGRIND_OPTS --suppressions=../memcheck-dlopen.supp" fi local REMOTE_VALGRIND_LOG=0 if [ "$CHECK_TYPE" != "none" ]; then case "$1" in run_on_node) REMOTE_VALGRIND_LOG=1 trace="$1 $2 $trace" [ $# -ge 2 ] && shift 2 || shift $# ;; run_on_node_background) trace="$1 $2 $3 $trace" [ $# -ge 3 ] && shift 3 || shift $# ;; wait_on_node|wait_on_node_port|kill_on_node) [ "$1" = "wait_on_node" ] && REMOTE_VALGRIND_LOG=1 trace="$1 $2 $3 $4" [ $# -ge 4 ] && shift 4 || shift $# ;; esac fi if [ "$CHECK_TYPE" = "drd" ]; then export VALGRIND_OPTS="$VALGRIND_OPTS --suppressions=../drd-log.supp" fi disable_exit_on_error eval $ECHO $trace "$*" ret=$? if [ $REMOTE_VALGRIND_LOG -eq 1 ]; then for node in $CHECK_NODES do local new_log_file=node\_$node\_$VALGRIND_LOG_FILE copy_files_from_node $node "." ${NODE_TEST_DIR[$node]}/$VALGRIND_LOG_FILE mv $VALGRIND_LOG_FILE $new_log_file done fi restore_exit_on_error if [ "$ret" -ne "0" ]; then if [ "$ret" -gt "128" ]; then msg="crashed (signal $(($ret - 128)))" else msg="failed with exit code $ret" fi msg=$(interactive_red STDERR $msg) if [ -f $ERR_LOG_FILE ]; then if [ "$UNITTEST_LOG_LEVEL" -ge "1" ]; then echo -e "$UNITTEST_NAME $msg. $ERR_LOG_FILE below." >&2 cat $ERR_LOG_FILE >&2 else echo -e "$UNITTEST_NAME $msg. $ERR_LOG_FILE above." >&2 fi else echo -e "$UNITTEST_NAME $msg." >&2 fi # ignore Ctrl-C if [ $ret != 130 ]; then for f in $(get_files ".*[a-zA-Z_]${UNITTEST_NUM}\.log"); do dump_last_n_lines $f done fi [ $NODES_MAX -ge 0 ] && clean_all_remote_nodes false fi if [ "$CHECK_TYPE" != "none" ]; then if [ $REMOTE_VALGRIND_LOG -eq 1 ]; then for node in $CHECK_NODES do local log_file=node\_$node\_$VALGRIND_LOG_FILE valgrind_ignore_warnings $new_log_file valgrind_ignore_messages $new_log_file validate_valgrind_log $new_log_file done else if [ -f $VALGRIND_LOG_FILE ]; then valgrind_ignore_warnings $VALGRIND_LOG_FILE valgrind_ignore_messages $VALGRIND_LOG_FILE validate_valgrind_log $VALGRIND_LOG_FILE fi fi fi if [ "$MEMCHECK_DONT_CHECK_LEAKS" = "1" -a "$CHECK_TYPE" = "memcheck" ]; then export ASAN_OPTIONS="${OLD_ASAN_OPTIONS}" fi } # # expect_abnormal_exit -- run a given command, expect it to exit non-zero # function expect_abnormal_exit() { if [ -n "$TRACE" ]; then case "$1" in *_on_node*) msg "$UNITTEST_NAME: SKIP: TRACE is not supported if test is executed on remote nodes" exit 0 esac fi if [ "$CHECK_TYPE" = "drd" ]; then export VALGRIND_OPTS="$VALGRIND_OPTS --suppressions=../drd-log.supp" fi disable_exit_on_error eval $ECHO ASAN_OPTIONS="detect_leaks=0 ${ASAN_OPTIONS}" $TRACE "$*" ret=$? restore_exit_on_error if [ "$ret" -eq "0" ]; then msg=$(interactive_red STDERR "succeeded") echo -e "$UNITTEST_NAME command $msg unexpectedly." >&2 [ $NODES_MAX -ge 0 ] && clean_all_remote_nodes false fi } # # check_pool -- run pmempool check on specified pool file # function check_pool() { if [ "$CHECK_POOL" == "1" ] then if [ "$VERBOSE" != "0" ] then echo "$UNITTEST_NAME: checking consistency of pool ${1}" fi ${PMEMPOOL}.static-nondebug check $1 2>&1 1>>$CHECK_POOL_LOG_FILE fi } # # check_pools -- run pmempool check on specified pool files # function check_pools() { if [ "$CHECK_POOL" == "1" ] then for f in $* do check_pool $f done fi } # # require_unlimited_vm -- require unlimited virtual memory # # This implies requirements for: # - overcommit_memory enabled (/proc/sys/vm/overcommit_memory is 0 or 1) # - unlimited virtual memory (ulimit -v is unlimited) # function require_unlimited_vm() { $VM_OVERCOMMIT && [ $(ulimit -v) = "unlimited" ] && return msg "$UNITTEST_NAME: SKIP required: overcommit_memory enabled and unlimited virtual memory" exit 0 } # # require_linked_with_ndctl -- require an executable linked with libndctl # # usage: require_linked_with_ndctl <executable-file> # function require_linked_with_ndctl() { [ "$1" == "" -o ! -x "$1" ] && \ fatal "$UNITTEST_NAME: ERROR: require_linked_with_ndctl() requires one argument - an executable file" local lddndctl=$(ldd $1 | $GREP -ce "libndctl") [ "$lddndctl" == "1" ] && return msg "$UNITTEST_NAME: SKIP required: executable $1 linked with libndctl" exit 0 } # # require_sudo_allowed -- require sudo command is allowed # function require_sudo_allowed() { if [ "$ENABLE_SUDO_TESTS" != "y" ]; then msg "$UNITTEST_NAME: SKIP: tests using 'sudo' are not enabled in testconfig.sh (ENABLE_SUDO_TESTS)" exit 0 fi if ! sh -c "timeout --signal=SIGKILL --kill-after=3s 3s sudo date" >/dev/null 2>&1 then msg "$UNITTEST_NAME: SKIP required: sudo allowed" exit 0 fi } # # require_sudo_allowed_node -- require sudo command on a remote node # # usage: require_sudo_allowed_node <node-number> # function require_sudo_allowed_node() { if [ "$ENABLE_SUDO_TESTS" != "y" ]; then msg "$UNITTEST_NAME: SKIP: tests using 'sudo' are not enabled in testconfig.sh (ENABLE_SUDO_TESTS)" exit 0 fi if ! run_on_node $1 "timeout --signal=SIGKILL --kill-after=3s 3s sudo date" >/dev/null 2>&1 then msg "$UNITTEST_NAME: SKIP required: sudo allowed on node $1" exit 0 fi } # # require_no_superuser -- require user without superuser rights # function require_no_superuser() { local user_id=$(id -u) [ "$user_id" != "0" ] && return msg "$UNITTEST_NAME: SKIP required: run without superuser rights" exit 0 } # # require_no_freebsd -- Skip test on FreeBSD # function require_no_freebsd() { [ "$(uname -s)" != "FreeBSD" ] && return msg "$UNITTEST_NAME: SKIP: Not supported on FreeBSD" exit 0 } # # require_procfs -- Skip test if /proc is not mounted # function require_procfs() { mount | grep -q "/proc" && return msg "$UNITTEST_NAME: SKIP: /proc not mounted" exit 0 } # # require_arch -- Skip tests if the running platform not matches # any of the input list. # function require_arch() { for i in "$@"; do [[ "$(uname -m)" == "$i" ]] && return done msg "$UNITTEST_NAME: SKIP: Only supported on $1" exit 0 } # # exclude_arch -- Skip tests if the running platform matches # any of the input list. # function exclude_arch() { for i in "$@"; do if [[ "$(uname -m)" == "$i" ]]; then msg "$UNITTEST_NAME: SKIP: Not supported on $1" exit 0 fi done } # # require_x86_64 -- Skip tests if the running platform is not x86_64 # function require_x86_64() { require_arch x86_64 } # # require_ppc64 -- Skip tests if the running platform is not ppc64 or ppc64le # function require_ppc64() { require_arch "ppc64" "ppc64le" "ppc64el" } # # exclude_ppc64 -- Skip tests if the running platform is ppc64 or ppc64le # function exclude_ppc64() { exclude_arch "ppc64" "ppc64le" "ppc64el" } # # require_test_type -- only allow script to continue for a certain test type # function require_test_type() { req_test_type=1 for type in $* do case "$TEST" in all) # "all" is a synonym of "short + medium + long" return ;; check) # "check" is a synonym of "short + medium" [ "$type" = "short" -o "$type" = "medium" ] && return ;; *) [ "$type" = "$TEST" ] && return ;; esac done verbose_msg "$UNITTEST_NAME: SKIP test-type $TEST ($* required)" exit 0 } # # require_dev_dax_region -- check if region id file exist for dev dax # function require_dev_dax_region() { local prefix="$UNITTEST_NAME: SKIP" local cmd="$PMEMDETECT -r" for path in ${DEVICE_DAX_PATH[@]} do disable_exit_on_error out=$($cmd $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" == "0" ]; then continue elif [ "$ret" == "1" ]; then msg "$prefix $out" exit 0 else fatal "$UNITTEST_NAME: pmemdetect: $out" fi done DEVDAX_TO_LOCK=1 } # # lock_devdax -- acquire a lock on Device DAXes # lock_devdax() { exec {DEVDAX_LOCK_FD}> $DEVDAX_LOCK flock $DEVDAX_LOCK_FD } # # unlock_devdax -- release a lock on Device DAXes # unlock_devdax() { flock -u $DEVDAX_LOCK_FD eval "exec ${DEVDAX_LOCK_FD}>&-" } # # require_dev_dax_node -- common function for require_dax_devices and # node_require_dax_device # # usage: require_dev_dax_node <N devices> [<node>] # function require_dev_dax_node() { req_dax_dev=1 if [ "$req_dax_dev_align" == "1" ]; then fatal "$UNITTEST_NAME: Do not use 'require_(node_)dax_devices' and " "'require_(node_)dax_device_alignments' together. Use the latter instead." fi local min=$1 local node=$2 if [ -n "$node" ]; then local DIR=${NODE_WORKING_DIR[$node]}/$curtestdir local prefix="$UNITTEST_NAME: SKIP NODE $node:" local device_dax_path=(${NODE_DEVICE_DAX_PATH[$node]}) if [ ${#device_dax_path[@]} -lt $min ]; then msg "$prefix NODE_${node}_DEVICE_DAX_PATH does not specify enough dax devices (min: $min)" exit 0 fi local cmd="ssh $SSH_OPTS ${NODE[$node]} cd $DIR && LD_LIBRARY_PATH=$REMOTE_LD_LIBRARY_PATH ../pmemdetect -d" else local prefix="$UNITTEST_NAME: SKIP" if [ ${#DEVICE_DAX_PATH[@]} -lt $min ]; then msg "$prefix DEVICE_DAX_PATH does not specify enough dax devices (min: $min)" exit 0 fi local device_dax_path=${DEVICE_DAX_PATH[@]} local cmd="$PMEMDETECT -d" fi for path in ${device_dax_path[@]} do disable_exit_on_error out=$($cmd $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" == "0" ]; then continue elif [ "$ret" == "1" ]; then msg "$prefix $out" exit 0 else fatal "$UNITTEST_NAME: pmemdetect: $out" fi done DEVDAX_TO_LOCK=1 } # # require_ndctl_enable -- check NDCTL_ENABLE value and skip test if set to 'n' # function require_ndctl_enable() { if ! is_ndctl_enabled $PMEMPOOL$EXE &> /dev/null ; then msg "$UNITTEST_NAME: SKIP: ndctl is disabled - binary not compiled with libndctl" exit 0 fi return 0 } # # require_dax_devices -- only allow script to continue if there is a required # number of Device DAX devices and ndctl is available # function require_dax_devices() { require_ndctl_enable require_pkg libndctl "$NDCTL_MIN_VERSION" REQUIRE_DAX_DEVICES=$1 require_dev_dax_node $1 } # # require_node_dax_device -- only allow script to continue if specified node # has enough Device DAX devices defined in testconfig.sh # function require_node_dax_device() { validate_node_number $1 require_dev_dax_node $2 $1 } # # require_no_unicode -- overwrite unicode suffix to empty string # function require_no_unicode() { export SUFFIX="" } # # get_node_devdax_path -- get path of a Device DAX device on a node # # usage: get_node_devdax_path <node> <device> # get_node_devdax_path() { local node=$1 local device=$2 local device_dax_path=(${NODE_DEVICE_DAX_PATH[$node]}) echo ${device_dax_path[$device]} } # # dax_device_zero -- zero all local dax devices # dax_device_zero() { for path in ${DEVICE_DAX_PATH[@]} do ${PMEMPOOL}.static-debug rm -f $path done } # # node_dax_device_zero -- zero all dax devices on a node # node_dax_device_zero() { local node=$1 local DIR=${NODE_WORKING_DIR[$node]}/$curtestdir local prefix="$UNITTEST_NAME: SKIP NODE $node:" local device_dax_path=(${NODE_DEVICE_DAX_PATH[$node]}) local cmd="ssh $SSH_OPTS ${NODE[$node]} cd $DIR && LD_LIBRARY_PATH=$REMOTE_LD_LIBRARY_PATH ../pmempool rm -f" for path in ${device_dax_path[@]} do disable_exit_on_error out=$($cmd $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" == "0" ]; then continue elif [ "$ret" == "1" ]; then msg "$prefix $out" exit 0 else fatal "$UNITTEST_NAME: pmempool rm: $out" fi done } # # get_devdax_size -- get the size of a device dax # function get_devdax_size() { local device=$1 local path=${DEVICE_DAX_PATH[$device]} local major_hex=$(stat -c "%t" $path) local minor_hex=$(stat -c "%T" $path) local major_dec=$((16#$major_hex)) local minor_dec=$((16#$minor_hex)) cat /sys/dev/char/$major_dec:$minor_dec/size } # # get_node_devdax_size -- get the size of a device dax on a node # function get_node_devdax_size() { local node=$1 local device=$2 local device_dax_path=(${NODE_DEVICE_DAX_PATH[$node]}) local path=${device_dax_path[$device]} local cmd_prefix="ssh $SSH_OPTS ${NODE[$node]} " disable_exit_on_error out=$($cmd_prefix stat -c %t $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" != "0" ]; then fatal "$UNITTEST_NAME: stat on node $node: $out" fi local major=$((16#$out)) disable_exit_on_error out=$($cmd_prefix stat -c %T $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" != "0" ]; then fatal "$UNITTEST_NAME: stat on node $node: $out" fi local minor=$((16#$out)) disable_exit_on_error out=$($cmd_prefix "cat /sys/dev/char/$major:$minor/size" 2>&1) ret=$? restore_exit_on_error if [ "$ret" != "0" ]; then fatal "$UNITTEST_NAME: stat on node $node: $out" fi echo $out } # # require_dax_device_node_alignments -- only allow script to continue if # the internal Device DAX alignments on a remote nodes are as specified. # If necessary, it sorts DEVICE_DAX_PATH entries to match # the requested alignment order. # # usage: require_node_dax_device_alignments <node> <alignment1> [ alignment2 ... ] # function require_node_dax_device_alignments() { req_dax_dev_align=1 if [ "$req_dax_dev" == "$1" ]; then fatal "$UNITTEST_NAME: Do not use 'require_(node_)dax_devices' and " "'require_(node_)dax_device_alignments' together. Use the latter instead." fi local node=$1 shift if [ "$node" == "-1" ]; then local device_dax_path=(${DEVICE_DAX_PATH[@]}) local cmd="$PMEMDETECT -a" else local device_dax_path=(${NODE_DEVICE_DAX_PATH[$node]}) local DIR=${NODE_WORKING_DIR[$node]}/$curtestdir local cmd="ssh $SSH_OPTS ${NODE[$node]} cd $DIR && LD_LIBRARY_PATH=$REMOTE_LD_LIBRARY_PATH ../pmemdetect -a" fi local cnt=${#device_dax_path[@]} local j=0 for alignment in $* do for (( i=j; i<cnt; i++ )) do path=${device_dax_path[$i]} disable_exit_on_error out=$($cmd $alignment $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" == "0" ]; then if [ $i -ne $j ]; then # swap device paths tmp=${device_dax_path[$j]} device_dax_path[$j]=$path device_dax_path[$i]=$tmp if [ "$node" == "-1" ]; then DEVICE_DAX_PATH=(${device_dax_path[@]}) else NODE_DEVICE_DAX_PATH[$node]=${device_dax_path[@]} fi fi break fi done if [ $i -eq $cnt ]; then if [ "$node" == "-1" ]; then msg "$UNITTEST_NAME: SKIP DEVICE_DAX_PATH"\ "does not specify enough dax devices or they don't have required alignments (min: $#, alignments: $*)" else msg "$UNITTEST_NAME: SKIP NODE $node: NODE_${node}_DEVICE_DAX_PATH"\ "does not specify enough dax devices or they don't have required alignments (min: $#, alignments: $*)" fi exit 0 fi j=$(( j + 1 )) done } # # require_dax_device_alignments -- only allow script to continue if # the internal Device DAX alignments are as specified. # If necessary, it sorts DEVICE_DAX_PATH entries to match # the requested alignment order. # # usage: require_dax_device_alignments alignment1 [ alignment2 ... ] # require_dax_device_alignments() { require_node_dax_device_alignments -1 $* } # # disable_eatmydata -- ensure invalid msyncs fail # # Distros (and people) like to use eatmydata to kill fsync-likes during builds # and testing. This is nice for speed, but we actually rely on msync failing # in some tests. # disable_eatmydata() { export LD_PRELOAD="${LD_PRELOAD/#libeatmydata.so/}" export LD_PRELOAD="${LD_PRELOAD/ libeatmydata.so/}" export LD_PRELOAD="${LD_PRELOAD/:libeatmydata.so/}" } # # require_fs_type -- only allow script to continue for a certain fs type # function require_fs_type() { req_fs_type=1 for type in $* do # treat any as either pmem or non-pmem [ "$type" = "$FS" ] || ([ -n "${FORCE_FS:+x}" ] && [ "$type" = "any" ] && [ "$FS" != "none" ]) && return done verbose_msg "$UNITTEST_NAME: SKIP fs-type $FS ($* required)" exit 0 } # # require_native_fallocate -- verify if filesystem supports fallocate # function require_native_fallocate() { require_fs_type pmem non-pmem set +e $FALLOCATE_DETECT $1 status=$? set -e if [ $status -eq 1 ]; then msg "$UNITTEST_NAME: SKIP: filesystem does not support fallocate" exit 0 elif [ $status -ne 0 ]; then msg "$UNITTEST_NAME: fallocate_detect failed" exit 1 fi } # # require_usc_permission -- verify if usc can be read with current permissions # function require_usc_permission() { set +e $USC_PERMISSION $1 2> $DIR/usc_permission.txt status=$? set -e # check if there were any messages printed to stderr, skip test if there were usc_stderr=$(cat $DIR/usc_permission.txt | wc -c) rm -f $DIR/usc_permission.txt if [ $status -eq 1 ] || [ $usc_stderr -ne 0 ]; then msg "$UNITTEST_NAME: SKIP: missing permissions to read usc" exit 0 elif [ $status -ne 0 ]; then msg "$UNITTEST_NAME: usc_permission_check failed" exit 1 fi } # # require_fs_name -- verify if the $DIR is on the required file system # # Must be AFTER setup() because $DIR must exist # function require_fs_name() { fsname=`df $DIR -PT | awk '{if (NR == 2) print $2}'` for name in $* do if [ "$name" == "$fsname" ]; then return fi done msg "$UNITTEST_NAME: SKIP file system $fsname ($* required)" exit 0 } # # require_build_type -- only allow script to continue for a certain build type # function require_build_type() { for type in $* do [ "$type" = "$BUILD" ] && return done verbose_msg "$UNITTEST_NAME: SKIP build-type $BUILD ($* required)" exit 0 } # # require_command -- only allow script to continue if specified command exists # function require_command() { if ! which $1 >/dev/null 2>&1; then msg "$UNITTEST_NAME: SKIP: '$1' command required" exit 0 fi } # # require_command_node -- only allow script to continue if specified command exists on a remote node # # usage: require_command_node <node-number> # function require_command_node() { if ! run_on_node $1 "which $2 >/dev/null 2>&1"; then msg "$UNITTEST_NAME: SKIP: node $1: '$2' command required" exit 0 fi } # # require_kernel_module -- only allow script to continue if specified kernel module exists # # usage: require_kernel_module <module_name> [path_to_modinfo] # function require_kernel_module() { MODULE=$1 MODINFO=$2 if [ "$MODINFO" == "" ]; then set +e [ "$MODINFO" == "" ] && \ MODINFO=$(which modinfo 2>/dev/null) set -e [ "$MODINFO" == "" ] && \ [ -x /usr/sbin/modinfo ] && MODINFO=/usr/sbin/modinfo [ "$MODINFO" == "" ] && \ [ -x /sbin/modinfo ] && MODINFO=/sbin/modinfo [ "$MODINFO" == "" ] && \ msg "$UNITTEST_NAME: SKIP: modinfo command required" && \ exit 0 else [ ! -x $MODINFO ] && \ msg "$UNITTEST_NAME: SKIP: modinfo command required" && \ exit 0 fi $MODINFO -F name $MODULE &>/dev/null && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP: '$MODULE' kernel module required" exit 0 fi } # # require_kernel_module_node -- only allow script to continue if specified kernel module exists on a remote node # # usage: require_kernel_module_node <node> <module_name> [path_to_modinfo] # function require_kernel_module_node() { NODE_N=$1 MODULE=$2 MODINFO=$3 if [ "$MODINFO" == "" ]; then set +e [ "$MODINFO" == "" ] && \ MODINFO=$(run_on_node $NODE_N which modinfo 2>/dev/null) set -e [ "$MODINFO" == "" ] && \ run_on_node $NODE_N "test -x /usr/sbin/modinfo" && MODINFO=/usr/sbin/modinfo [ "$MODINFO" == "" ] && \ run_on_node $NODE_N "test -x /sbin/modinfo" && MODINFO=/sbin/modinfo [ "$MODINFO" == "" ] && \ msg "$UNITTEST_NAME: SKIP: node $NODE_N: modinfo command required" && \ exit 0 else run_on_node $NODE_N "test ! -x $MODINFO" && \ msg "$UNITTEST_NAME: SKIP: node $NODE_N: modinfo command required" && \ exit 0 fi run_on_node $NODE_N "$MODINFO -F name $MODULE &>/dev/null" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP: node $NODE_N: '$MODULE' kernel module required" exit 0 fi } # # require_pkg -- only allow script to continue if specified package exists # usage: require_pkg <package name> [<package minimal version>] # function require_pkg() { if ! command -v pkg-config 1>/dev/null then msg "$UNITTEST_NAME: SKIP pkg-config required" exit 0 fi local COMMAND="pkg-config $1" local MSG="$UNITTEST_NAME: SKIP '$1' package" if [ "$#" -eq "2" ]; then COMMAND="$COMMAND --atleast-version $2" MSG="$MSG (version >= $2)" fi MSG="$MSG required" if ! $COMMAND then msg "$MSG" exit 0 fi } # # require_node_pkg -- only allow script to continue if specified package exists # on specified node # usage: require_node_pkg <node> <package name> [<package minimal version>] # function require_node_pkg() { validate_node_number $1 local N=$1 shift local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir local COMMAND="${NODE_ENV[$N]}" if [ -n "${NODE_LD_LIBRARY_PATH[$N]}" ]; then local PKG_CONFIG_PATH=${NODE_LD_LIBRARY_PATH[$N]//:/\/pkgconfig:}/pkgconfig COMMAND="$COMMAND PKG_CONFIG_PATH=\$PKG_CONFIG_PATH:$PKG_CONFIG_PATH" fi COMMAND="$COMMAND PKG_CONFIG_PATH=$REMOTE_PKG_CONFIG_PATH" COMMAND="$COMMAND pkg-config $1" MSG="$UNITTEST_NAME: SKIP NODE $N: '$1' package" if [ "$#" -eq "2" ]; then COMMAND="$COMMAND --atleast-version $2" MSG="$MSG (version >= $2)" fi MSG="$MSG required" disable_exit_on_error run_command ssh $SSH_OPTS ${NODE[$N]} "$COMMAND" 2>&1 ret=$? restore_exit_on_error if [ "$ret" == 1 ]; then msg "$MSG" exit 0 fi } # # configure_valgrind -- only allow script to continue when settings match # function configure_valgrind() { case "$1" in memcheck|pmemcheck|helgrind|drd|force-disable) ;; *) usage "bad test-type: $1" ;; esac if [ "$CHECK_TYPE" == "none" ]; then if [ "$1" == "force-disable" ]; then msg "$UNITTEST_NAME: all valgrind tests disabled" elif [ "$2" = "force-enable" ]; then CHECK_TYPE="$1" require_valgrind_tool $1 $3 elif [ "$2" = "force-disable" ]; then CHECK_TYPE=none else fatal "invalid parameter" fi else if [ "$1" == "force-disable" ]; then msg "$UNITTEST_NAME: SKIP RUNTESTS script parameter $CHECK_TYPE tries to enable valgrind test when all valgrind tests are disabled in TEST" exit 0 elif [ "$CHECK_TYPE" != "$1" -a "$2" == "force-enable" ]; then msg "$UNITTEST_NAME: SKIP RUNTESTS script parameter $CHECK_TYPE tries to enable different valgrind test than one defined in TEST" exit 0 elif [ "$CHECK_TYPE" == "$1" -a "$2" == "force-disable" ]; then msg "$UNITTEST_NAME: SKIP RUNTESTS script parameter $CHECK_TYPE tries to enable test defined in TEST as force-disable" exit 0 fi require_valgrind_tool $CHECK_TYPE $3 fi if [ "$UT_VALGRIND_SKIP_PRINT_MISMATCHED" == 1 ]; then export UT_SKIP_PRINT_MISMATCHED=1 fi } # # valgrind_version_no_check -- returns Valgrind version without checking # for valgrind first # function valgrind_version_no_check() { $VALGRINDEXE --version | sed "s/valgrind-\([0-9]*\)\.\([0-9]*\).*/\1*100+\2/" | bc } # # require_valgrind -- continue script execution only if # valgrind package is installed # function require_valgrind() { # bc is used inside valgrind_version_no_check require_command bc require_no_asan disable_exit_on_error VALGRINDEXE=`which valgrind 2>/dev/null` local ret=$? restore_exit_on_error if [ $ret -ne 0 ]; then msg "$UNITTEST_NAME: SKIP valgrind required" exit 0 fi [ $NODES_MAX -lt 0 ] && return; if [ ! -z "$1" ]; then available=$(valgrind_version_no_check) required=`echo $1 | sed "s/\([0-9]*\)\.\([0-9]*\).*/\1*100+\2/" | bc` if [ $available -lt $required ]; then msg "$UNITTEST_NAME: SKIP valgrind required (ver $1 or later)" exit 0 fi fi for N in $NODES_SEQ; do if [ "${NODE_VALGRINDEXE[$N]}" = "" ]; then disable_exit_on_error NODE_VALGRINDEXE[$N]=$(ssh $SSH_OPTS ${NODE[$N]} "which valgrind 2>/dev/null") ret=$? restore_exit_on_error if [ $ret -ne 0 ]; then msg "$UNITTEST_NAME: SKIP valgrind required on remote node #$N" exit 0 fi fi done } # # valgrind_version -- returns Valgrind version # function valgrind_version() { require_valgrind valgrind_version_no_check } # # require_valgrind_tool -- continue script execution only if valgrind with # specified tool is installed # # usage: require_valgrind_tool <tool> [<binary>] # function require_valgrind_tool() { require_valgrind local tool=$1 local binary=$2 local dir=. [ -d "$2" ] && dir="$2" && binary= pushd "$dir" > /dev/null [ -n "$binary" ] || binary=$(get_executables) if [ -z "$binary" ]; then fatal "require_valgrind_tool: error: no binary found" fi strings ${binary} 2>&1 | \ grep -q "compiled with support for Valgrind $tool" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP not compiled with support for Valgrind $tool" exit 0 fi if [ "$tool" == "helgrind" ]; then valgrind --tool=$tool --help 2>&1 | \ grep -qi "$tool is Copyright (c)" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP Valgrind with $tool required" exit 0; fi fi if [ "$tool" == "pmemcheck" ]; then out=`valgrind --tool=$tool --help 2>&1` && true echo "$out" | grep -qi "$tool is Copyright (c)" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP Valgrind with $tool required" exit 0; fi echo "$out" | grep -qi "expect-fence-after-clflush" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP pmemcheck does not support --expect-fence-after-clflush option. Please update it to the latest version." exit 0; fi fi popd > /dev/null return 0 } # # set_valgrind_exe_name -- set the actual Valgrind executable name # # On some systems (Ubuntu), "valgrind" is a shell script that calls # the actual executable "valgrind.bin". # The wrapper script doesn't work well with LD_PRELOAD, so we want # to call Valgrind directly. # function set_valgrind_exe_name() { if [ "$VALGRINDEXE" = "" ]; then fatal "set_valgrind_exe_name: error: valgrind is not set up" fi local VALGRINDDIR=`dirname $VALGRINDEXE` if [ -x $VALGRINDDIR/valgrind.bin ]; then VALGRINDEXE=$VALGRINDDIR/valgrind.bin fi [ $NODES_MAX -lt 0 ] && return; for N in $NODES_SEQ; do local COMMAND="\ [ -x $(dirname ${NODE_VALGRINDEXE[$N]})/valgrind.bin ] && \ echo $(dirname ${NODE_VALGRINDEXE[$N]})/valgrind.bin || \ echo ${NODE_VALGRINDEXE[$N]}" NODE_VALGRINDEXE[$N]=$(ssh $SSH_OPTS ${NODE[$N]} $COMMAND) if [ $? -ne 0 ]; then fatal ${NODE_VALGRINDEXE[$N]} fi done } # # require_no_asan_for - continue script execution only if passed binary does # NOT require libasan # function require_no_asan_for() { disable_exit_on_error nm $1 | grep -q __asan_ ASAN_ENABLED=$? restore_exit_on_error if [ "$ASAN_ENABLED" == "0" ]; then msg "$UNITTEST_NAME: SKIP: ASAN enabled" exit 0 fi } # # require_cxx11 -- continue script execution only if C++11 supporting compiler # is installed # function require_cxx11() { [ "$CXX" ] || CXX=c++ CXX11_AVAILABLE=`echo "int main(){return 0;}" |\ $CXX -std=c++11 -x c++ -o /dev/null - 2>/dev/null &&\ echo y || echo n` if [ "$CXX11_AVAILABLE" == "n" ]; then msg "$UNITTEST_NAME: SKIP: C++11 required" exit 0 fi } # # require_no_asan - continue script execution only if libpmem does NOT require # libasan # function require_no_asan() { case "$BUILD" in debug) require_no_asan_for ../../debug/libpmem.so ;; nondebug) require_no_asan_for ../../nondebug/libpmem.so ;; static-debug) require_no_asan_for ../../debug/libpmem.a ;; static-nondebug) require_no_asan_for ../../nondebug/libpmem.a ;; esac } # # require_tty - continue script execution only if standard output is a terminal # function require_tty() { if ! tty >/dev/null; then msg "$UNITTEST_NAME: SKIP no terminal" exit 0 fi } # # require_binary -- continue script execution only if the binary has been compiled # # In case of conditional compilation, skip this test. # function require_binary() { if [ -z "$1" ]; then fatal "require_binary: error: binary not provided" fi if [ ! -x "$1" ]; then msg "$UNITTEST_NAME: SKIP no binary found" exit 0 fi return } # # require_sds -- continue script execution only if binary is compiled with # shutdown state support # # usage: require_sds <binary> # function require_sds() { local binary=$1 local dir=. if [ -z "$binary" ]; then fatal "require_sds: error: no binary found" fi strings ${binary} 2>&1 | \ grep -q "compiled with support for shutdown state" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP not compiled with support for shutdown state" exit 0 fi return 0 } # # require_no_sds -- continue script execution only if binary is NOT compiled with # shutdown state support # # usage: require_no_sds <binary> # function require_no_sds() { local binary=$1 local dir=. if [ -z "$binary" ]; then fatal "require_sds: error: no binary found" fi set +e found=$(strings ${binary} 2>&1 | \ grep -c "compiled with support for shutdown state") set -e if [ "$found" -ne "0" ]; then msg "$UNITTEST_NAME: SKIP compiled with support for shutdown state" exit 0 fi return 0 } # # is_ndctl_enabled -- check if binary is compiled with libndctl # # usage: is_ndctl_enabled <binary> # function is_ndctl_enabled() { local binary=$1 local dir=. if [ -z "$binary" ]; then fatal "is_ndctl_enabled: error: no binary found" fi strings ${binary} 2>&1 | \ grep -q "compiled with libndctl" && true return $? } # # require_bb_enabled_by_default -- check if the binary has bad block # checking feature enabled by default # # usage: require_bb_enabled_by_default <binary> # function require_bb_enabled_by_default() { if ! is_ndctl_enabled $1 &> /dev/null ; then msg "$UNITTEST_NAME: SKIP bad block checking feature disabled by default" exit 0 fi return 0 } # # require_bb_disabled_by_default -- check if the binary does not have bad # block checking feature enabled by default # # usage: require_bb_disabled_by_default <binary> # function require_bb_disabled_by_default() { if is_ndctl_enabled $1 &> /dev/null ; then msg "$UNITTEST_NAME: SKIP bad block checking feature enabled by default" exit 0 fi return 0 } # # check_absolute_path -- continue script execution only if $DIR path is # an absolute path; do not resolve symlinks # function check_absolute_path() { if [ "${DIR:0:1}" != "/" ]; then fatal "Directory \$DIR has to be an absolute path. $DIR was given." fi } # # run_command -- run a command in a verbose or quiet way # function run_command() { local COMMAND="$*" if [ "$VERBOSE" != "0" ]; then echo "$ $COMMAND" $COMMAND else $COMMAND fi } # # validate_node_number -- validate a node number # function validate_node_number() { [ $1 -gt $NODES_MAX ] \ && fatal "error: node number ($1) greater than maximum allowed node number ($NODES_MAX)" return 0 } # # clean_remote_node -- usage: clean_remote_node <node> <list-of-pid-files> # function clean_remote_node() { validate_node_number $1 local N=$1 shift local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir # register the list of PID files to be cleaned in case of an error NODE_PID_FILES[$N]="${NODE_PID_FILES[$N]} $*" # clean the remote node disable_exit_on_error for pidfile in ${NODE_PID_FILES[$N]}; do require_ctrld_err $N $pidfile run_command ssh $SSH_OPTS ${NODE[$N]} "\ cd $DIR && [ -f $pidfile ] && \ ../ctrld $pidfile kill SIGINT && \ ../ctrld $pidfile wait 1 ; \ rm -f $pidfile" done; restore_exit_on_error return 0 } # # clean_all_remote_nodes -- clean all remote nodes in case of an error # function clean_all_remote_nodes() { msg "$UNITTEST_NAME: CLEAN (cleaning processes on remote nodes)" local N=0 disable_exit_on_error for N in $NODES_SEQ; do local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir for pidfile in ${NODE_PID_FILES[$N]}; do run_command ssh $SSH_OPTS ${NODE[$N]} "\ cd $DIR && [ -f $pidfile ] && \ ../ctrld $pidfile kill SIGINT && \ ../ctrld $pidfile wait 1 ; \ rm -f $pidfile" done done restore_exit_on_error return 0 } # # export_vars_node -- export specified variables on specified node # function export_vars_node() { local N=$1 shift validate_node_number $N for var in "$@"; do NODE_ENV[$N]="${NODE_ENV[$N]} $var=${!var}" done } # # require_nodes_libfabric -- only allow script to continue if libfabric with # optionally specified provider is available on # specified node # usage: require_nodes_libfabric <node> <provider> [<libfabric-version>] # function require_node_libfabric() { validate_node_number $1 local N=$1 local provider=$2 # Minimal required version of libfabric. # Keep in sync with requirements in src/common.inc. local version=${3:-1.4.2} require_pkg libfabric "$version" # fi_info can be found in libfabric-bin require_command fi_info require_node_pkg $N libfabric "$version" require_command_node $N fi_info if [ "$RPMEM_PROVIDER" == "verbs" ]; then if ! fi_info --list | grep -q verbs; then msg "$UNITTEST_NAME: SKIP libfabric not compiled with verbs provider" exit 0 fi if ! run_on_node $N "fi_info --list | grep -q verbs"; then msg "$UNITTEST_NAME: SKIP libfabric on node $N not compiled with verbs provider" exit 0 fi fi local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir local COMMAND="$COMMAND ${NODE_ENV[$N]}" COMMAND="$COMMAND LD_LIBRARY_PATH=${NODE_LD_LIBRARY_PATH[$N]}:$REMOTE_LD_LIBRARY_PATH" COMMAND="$COMMAND ../fip ${NODE_ADDR[$N]} $provider" disable_exit_on_error fip_out=$(ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && $COMMAND" 2>&1) ret=$? restore_exit_on_error if [ "$ret" == "0" ]; then return elif [ "$ret" == "1" ]; then msg "$UNITTEST_NAME: SKIP NODE $N: $fip_out" exit 0 else fatal "NODE $N: require_libfabric $provider: $fip_out" fi } # # check_if_node_is_reachable -- check if the $1 node is reachable # function check_if_node_is_reachable() { disable_exit_on_error run_command ssh $SSH_OPTS ${NODE[$1]} exit local ret=$? restore_exit_on_error return $ret } # # require_nodes -- only allow script to continue for a certain number # of defined and reachable nodes # # Input arguments: # NODE[] - (required) array of nodes' addresses # NODE_WORKING_DIR[] - (required) array of nodes' working directories # function require_nodes() { local N_NODES=${#NODE[@]} local N=$1 [ -z "$N" ] \ && fatal "require_nodes: missing reguired parameter: number of nodes" # if it has already been called, check if number of required nodes is bigger than previously [ -n "$NODES_MAX" ] \ && [ $(($N - 1)) -le $NODES_MAX ] && return [ $N -gt $N_NODES ] \ && msg "$UNITTEST_NAME: SKIP: requires $N node(s), but $N_NODES node(s) provided" \ && exit 0 NODES_MAX=$(($N - 1)) NODES_SEQ=$(seq -s' ' 0 $NODES_MAX) # check if all required nodes are reachable for N in $NODES_SEQ; do # validate node's address [ "${NODE[$N]}" = "" ] \ && msg "$UNITTEST_NAME: SKIP: address of node #$N is not provided" \ && exit 0 # validate the working directory [ "${NODE_WORKING_DIR[$N]}" = "" ] \ && fatal "error: working directory for node #$N (${NODE[$N]}) is not provided" # check if the node is reachable check_if_node_is_reachable $N [ $? -ne 0 ] \ && fatal "error: node #$N (${NODE[$N]}) is unreachable" # clear the list of PID files for each node NODE_PID_FILES[$N]="" NODE_TEST_DIR[$N]=${NODE_WORKING_DIR[$N]}/$curtestdir NODE_DIR[$N]=${NODE_WORKING_DIR[$N]}/$curtestdir/data/ require_node_log_files $N $ERR_LOG_FILE $OUT_LOG_FILE $TRACE_LOG_FILE if [ "$CHECK_TYPE" != "none" -a "${NODE_VALGRINDEXE[$N]}" = "" ]; then disable_exit_on_error NODE_VALGRINDEXE[$N]=$(ssh $SSH_OPTS ${NODE[$N]} "which valgrind 2>/dev/null") local ret=$? restore_exit_on_error if [ $ret -ne 0 ]; then msg "$UNITTEST_NAME: SKIP valgrind required on remote node #$N" exit 0 fi fi done # remove all log files of the current unit test from the required nodes # and export the 'log' variables to these nodes for N in $NODES_SEQ; do for f in $(get_files "node_${N}.*${UNITTEST_NUM}\.log"); do rm -f $f done export_vars_node $N $REMOTE_VARS done # register function to clean all remote nodes in case of an error or SIGINT trap clean_all_remote_nodes ERR SIGINT return 0 } # # check_files_on_node -- check if specified files exist on given node # function check_files_on_node() { validate_node_number $1 local N=$1 shift local REMOTE_DIR=${NODE_DIR[$N]} run_command ssh $SSH_OPTS ${NODE[$N]} "for f in $*; do if [ ! -f $REMOTE_DIR/\$f ]; then echo \"Missing file \$f on node #$N\" 1>&2; exit 1; fi; done" } # # check_no_files_on_node -- check if specified files does not exist on given node # function check_no_files_on_node() { validate_node_number $1 local N=$1 shift local REMOTE_DIR=${NODE_DIR[$N]} run_command ssh $SSH_OPTS ${NODE[$N]} "for f in $*; do if [ -f $REMOTE_DIR/\$f ]; then echo \"Not deleted file \$f on node #$N\" 1>&2; exit 1; fi; done" } # # copy_files_to_node -- copy all required files to the given remote node # usage: copy_files_to_node <node> <destination dir> <file_1> [<file_2>] ... # function copy_files_to_node() { validate_node_number $1 local N=$1 local DEST_DIR=$2 shift 2 [ $# -eq 0 ] &&\ fatal "error: copy_files_to_node(): no files provided" # copy all required files run_command scp $SCP_OPTS $@ ${NODE[$N]}:$DEST_DIR > /dev/null return 0 } # # copy_files_from_node -- copy all required files from the given remote node # usage: copy_files_from_node <node> <destination_dir> <file_1> [<file_2>] ... # function copy_files_from_node() { validate_node_number $1 local N=$1 local DEST_DIR=$2 [ ! -d $DEST_DIR ] &&\ fatal "error: destination directory $DEST_DIR does not exist" shift 2 [ $# -eq 0 ] &&\ fatal "error: copy_files_from_node(): no files provided" # compress required files, copy and extract local temp_file=node_${N}_temp_file.tar files="" dir_name="" files=$(basename -a $@) dir_name=$(dirname $1) run_command ssh $SSH_OPTS ${NODE[$N]} "cd $dir_name && tar -czf $temp_file $files" run_command scp $SCP_OPTS ${NODE[$N]}:$dir_name/$temp_file $DEST_DIR > /dev/null cd $DEST_DIR \ && tar -xzf $temp_file \ && rm $temp_file \ && cd - > /dev/null return 0 } # # copy_log_files -- copy log files from remote node # function copy_log_files() { local NODE_SCP_LOG_FILES[0]="" for N in $NODES_SEQ; do local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir for file in ${NODE_LOG_FILES[$N]}; do NODE_SCP_LOG_FILES[$N]="${NODE_SCP_LOG_FILES[$N]} ${NODE[$N]}:$DIR/${file}" done [ "${NODE_SCP_LOG_FILES[$N]}" ] && run_command scp $SCP_OPTS ${NODE_SCP_LOG_FILES[$N]} . &>> $PREP_LOG_FILE for file in ${NODE_LOG_FILES[$N]}; do [ -f $file ] && mv $file node_${N}_${file} done done } # # rm_files_from_node -- removes all listed files from the given remote node # usage: rm_files_from_node <node> <file_1> [<file_2>] ... # function rm_files_from_node() { validate_node_number $1 local N=$1 shift [ $# -eq 0 ] &&\ fatal "error: rm_files_from_node(): no files provided" run_command ssh $SSH_OPTS ${NODE[$N]} "rm -f $@" return 0 } # # # require_node_log_files -- store log files which must be copied from # specified node on failure # function require_node_log_files() { validate_node_number $1 local N=$1 shift NODE_LOG_FILES[$N]="${NODE_LOG_FILES[$N]} $*" } # # require_ctrld_err -- store ctrld's log files to copy from specified # node on failure # function require_ctrld_err() { local N=$1 local PID_FILE=$2 local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir for cmd in run wait kill wait_port; do NODE_LOG_FILES[$N]="${NODE_LOG_FILES[$N]} $PID_FILE.$cmd.ctrld.log" done } # # run_on_node -- usage: run_on_node <node> <command> # # Run the <command> in background on the remote <node>. # LD_LIBRARY_PATH for the n-th remote node can be provided # in the array NODE_LD_LIBRARY_PATH[n] # function run_on_node() { validate_node_number $1 local N=$1 shift local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir local COMMAND="UNITTEST_NUM=$UNITTEST_NUM UNITTEST_NAME=$UNITTEST_NAME" COMMAND="$COMMAND UNITTEST_LOG_LEVEL=1" COMMAND="$COMMAND ${NODE_ENV[$N]}" COMMAND="$COMMAND PATH=$REMOTE_PATH" COMMAND="$COMMAND LD_LIBRARY_PATH=${NODE_LD_LIBRARY_PATH[$N]}:$REMOTE_LD_LIBRARY_PATH $*" run_command ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && $COMMAND" ret=$? if [ "$ret" -ne "0" ]; then copy_log_files fi return $ret } # # run_on_node_background -- usage: # run_on_node_background <node> <pid-file> <command> # # Run the <command> in background on the remote <node> # and create a <pid-file> for this process. # LD_LIBRARY_PATH for the n-th remote node # can be provided in the array NODE_LD_LIBRARY_PATH[n] # function run_on_node_background() { validate_node_number $1 local N=$1 local PID_FILE=$2 shift shift local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir local COMMAND="UNITTEST_NUM=$UNITTEST_NUM UNITTEST_NAME=$UNITTEST_NAME" COMMAND="$COMMAND UNITTEST_LOG_LEVEL=1" COMMAND="$COMMAND ${NODE_ENV[$N]}" COMMAND="$COMMAND PATH=$REMOTE_PATH" COMMAND="$COMMAND LD_LIBRARY_PATH=${NODE_LD_LIBRARY_PATH[$N]}:$REMOTE_LD_LIBRARY_PATH" COMMAND="$COMMAND ../ctrld $PID_FILE run $RUNTEST_TIMEOUT $*" # register the PID file to be cleaned in case of an error NODE_PID_FILES[$N]="${NODE_PID_FILES[$N]} $PID_FILE" run_command ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && $COMMAND" ret=$? if [ "$ret" -ne "0" ]; then copy_log_files fi return $ret } # # wait_on_node -- usage: wait_on_node <node> <pid-file> [<timeout>] # # Wait until the process with the <pid-file> on the <node> # exits or <timeout> expires. # function wait_on_node() { validate_node_number $1 local N=$1 local PID_FILE=$2 local TIMEOUT=$3 local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir run_command ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && ../ctrld $PID_FILE wait $TIMEOUT" ret=$? if [ "$ret" -ne "0" ]; then copy_log_files fi return $ret } # # wait_on_node_port -- usage: wait_on_node_port <node> <pid-file> <portno> # # Wait until the process with the <pid-file> on the <node> # opens the port <portno>. # function wait_on_node_port() { validate_node_number $1 local N=$1 local PID_FILE=$2 local PORTNO=$3 local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir run_command ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && ../ctrld $PID_FILE wait_port $PORTNO" ret=$? if [ "$ret" -ne "0" ]; then copy_log_files fi return $ret } # # kill_on_node -- usage: kill_on_node <node> <pid-file> <signo> # # Send the <signo> signal to the process with the <pid-file> # on the <node>. # function kill_on_node() { validate_node_number $1 local N=$1 local PID_FILE=$2 local SIGNO=$3 local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir run_command ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && ../ctrld $PID_FILE kill $SIGNO" ret=$? if [ "$ret" -ne "0" ]; then copy_log_files fi return $ret } # # obj_pool_desc_size -- returns the obj_pool_desc_size macro value # in bytes which is two times the actual pagesize. # # This should be use to calculate the minimum zero size for pool # creation on some tests. # function obj_pool_desc_size() { echo "$(expr $(getconf PAGESIZE) \* 2)" } # # log_pool_desc_size -- returns the minimum size of pool header # in bytes which is two times the actual pagesize. # # This should be use to calculate the minimum zero size for pool # creation on some tests. # function log_pool_desc_size() { echo "$(expr $(getconf PAGESIZE) \* 2)" } # # blk_pool_desc_size -- returns the minimum size of pool header # in bytes which is two times the actual pagesize. # # This should be use to calculate the minimum zero size for pool # creation on some tests. # function blk_pool_desc_size() { echo "$(expr $(getconf PAGESIZE) \* 2)" } # # create_holey_file_on_node -- create holey files of a given length # usage: create_holey_file_on_node <node> <size> # # example, to create two files, each 1GB in size on node 0: # create_holey_file_on_node 0 1G testfile1 testfile2 # # Input unit size is in bytes with optional suffixes like k, KB, M, etc. # function create_holey_file_on_node() { validate_node_number $1 local N=$1 size=$(convert_to_bytes $2) shift 2 for file in $* do run_on_node $N truncate -s ${size} $file >> $PREP_LOG_FILE done } # # require_mmap_under_valgrind -- only allow script to continue if mapping is # possible under Valgrind with required length # (sum of required DAX devices size). # This function is being called internally in # setup() function. # function require_mmap_under_valgrind() { local FILE_MAX_DAX_DEVICES="../tools/anonymous_mmap/max_dax_devices" if [ -z "$REQUIRE_DAX_DEVICES" ]; then return fi if [ ! -f "$FILE_MAX_DAX_DEVICES" ]; then fatal "$FILE_MAX_DAX_DEVICES not found. Run make test." fi if [ "$REQUIRE_DAX_DEVICES" -gt "$(< $FILE_MAX_DAX_DEVICES)" ]; then msg "$UNITTEST_NAME: SKIP: anonymous mmap under Valgrind not possible for $REQUIRE_DAX_DEVICES DAX device(s)." exit 0 fi } # # setup -- print message that test setup is commencing # function setup() { DIR=$DIR$SUFFIX # writes test working directory to temporary file # that allows read location of data after test failure if [ -f "$TEMP_LOC" ]; then echo "$DIR" > $TEMP_LOC fi # test type must be explicitly specified if [ "$req_test_type" != "1" ]; then fatal "error: required test type is not specified" fi # fs type "none" must be explicitly enabled if [ "$FS" = "none" -a "$req_fs_type" != "1" ]; then exit 0 fi # fs type "any" must be explicitly enabled if [ "$FS" = "any" -a "$req_fs_type" != "1" ]; then exit 0 fi if [ "$CHECK_TYPE" != "none" ]; then require_valgrind # detect possible Valgrind mmap issues and skip uncertain tests require_mmap_under_valgrind export VALGRIND_LOG_FILE=$CHECK_TYPE${UNITTEST_NUM}.log MCSTR="/$CHECK_TYPE" else MCSTR="" fi [ -n "$RPMEM_PROVIDER" ] && PROV="/$RPMEM_PROVIDER" [ -n "$RPMEM_PM" ] && PM="/$RPMEM_PM" msg "$UNITTEST_NAME: SETUP ($TEST/$REAL_FS/$BUILD$MCSTR$PROV$PM)" for f in $(get_files ".*[a-zA-Z_]${UNITTEST_NUM}\.log"); do rm -f $f done # $DIR has to be an absolute path check_absolute_path if [ "$FS" != "none" ]; then if [ -d "$DIR" ]; then rm $RM_ONEFS -rf -- $DIR fi mkdir -p $DIR fi if [ "$TM" = "1" ]; then start_time=$($DATE +%s.%N) fi if [ "$DEVDAX_TO_LOCK" == 1 ]; then lock_devdax fi export PMEMBLK_CONF="fallocate.at_create=0;" export PMEMOBJ_CONF="fallocate.at_create=0;" export PMEMLOG_CONF="fallocate.at_create=0;" } # # check_log_empty -- if match file does not exist, assume log should be empty # function check_log_empty() { if [ ! -f ${1}.match ] && [ $(get_size $1) -ne 0 ]; then echo "unexpected output in $1" dump_last_n_lines $1 exit 1 fi } # # check_local -- check local test results (using .match files) # function check_local() { if [ "$UT_SKIP_PRINT_MISMATCHED" == 1 ]; then option=-q fi check_log_empty $ERR_LOG_FILE FILES=$(get_files "[^0-9w]*${UNITTEST_NUM}\.log\.match") if [ -n "$FILES" ]; then ../match $option $FILES fi } # # match -- execute match # function match() { ../match $@ } # # check -- check local or remote test results (using .match files) # function check() { if [ $NODES_MAX -lt 0 ]; then check_local else FILES=$(get_files "node_[0-9]+_[^0-9w]*${UNITTEST_NUM}\.log\.match") local NODE_MATCH_FILES[0]="" local NODE_SCP_MATCH_FILES[0]="" for file in $FILES; do local N=`echo $file | cut -d"_" -f2` local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir local FILE=`echo $file | cut -d"_" -f3 | sed "s/\.match$//g"` validate_node_number $N NODE_MATCH_FILES[$N]="${NODE_MATCH_FILES[$N]} $FILE" NODE_SCP_MATCH_FILES[$N]="${NODE_SCP_MATCH_FILES[$N]} ${NODE[$N]}:$DIR/$FILE" done for N in $NODES_SEQ; do [ "${NODE_SCP_MATCH_FILES[$N]}" ] && run_command scp $SCP_OPTS ${NODE_SCP_MATCH_FILES[$N]} . > /dev/null for file in ${NODE_MATCH_FILES[$N]}; do mv $file node_${N}_${file} done done if [ "$UT_SKIP_PRINT_MISMATCHED" == 1 ]; then option=-q fi for N in $NODES_SEQ; do check_log_empty node_${N}_${ERR_LOG_FILE} done if [ -n "$FILES" ]; then match $option $FILES fi fi # Move logs to build folder LOG_DIR=logs/$TEST/$REAL_FS/$BUILD$MCSTR$PROV$PM if [ ! -d $LOG_DIR ]; then mkdir --parents $LOG_DIR; fi for f in $(get_files ".*[a-zA-Z_]${UNITTEST_NUM}\.log"); do mv -f $f $LOG_DIR/$f done } # # pass -- print message that the test has passed # function pass() { if [ "$DEVDAX_TO_LOCK" == 1 ]; then unlock_devdax fi if [ "$TM" = "1" ]; then end_time=$($DATE +%s.%N) start_time_sec=$($DATE -d "0 $start_time sec" +%s) end_time_sec=$($DATE -d "0 $end_time sec" +%s) days=$(((end_time_sec - start_time_sec) / (24*3600))) days=$(printf "%03d" $days) tm=$($DATE -d "0 $end_time sec - $start_time sec" +%H:%M:%S.%N) tm=$(echo "$days:$tm" | sed -e "s/^000://g" -e "s/^00://g" -e "s/^00://g" -e "s/\([0-9]*\)\.\([0-9][0-9][0-9]\).*/\1.\2/") tm="\t\t\t[$tm s]" else tm="" fi msg=$(interactive_green STDOUT "PASS") if [ "$UNITTEST_LOG_LEVEL" -ge 1 ]; then echo -e "$UNITTEST_NAME: $msg$tm" fi if [ "$FS" != "none" ]; then rm $RM_ONEFS -rf -- $DIR fi } # Length of pool file's signature SIG_LEN=8 # Offset and length of pmemobj layout LAYOUT_OFFSET=$(getconf PAGE_SIZE) LAYOUT_LEN=1024 # Length of arena's signature ARENA_SIG_LEN=16 # Signature of BTT Arena ARENA_SIG="BTT_ARENA_INFO" # Offset to first arena ARENA_OFF=$(($(getconf PAGE_SIZE) * 2)) # # check_file -- check if file exists and print error message if not # check_file() { if [ ! -f $1 ] then fatal "Missing file: ${1}" fi } # # check_files -- check if files exist and print error message if not # check_files() { for file in $* do check_file $file done } # # check_no_file -- check if file has been deleted and print error message if not # check_no_file() { if [ -f $1 ] then fatal "Not deleted file: ${1}" fi } # # check_no_files -- check if files has been deleted and print error message if not # check_no_files() { for file in $* do check_no_file $file done } # # get_size -- return size of file (0 if file does not exist) # get_size() { if [ ! -f $1 ]; then echo "0" else stat $STAT_SIZE $1 fi } # # get_mode -- return mode of file # get_mode() { stat $STAT_MODE $1 } # # check_size -- validate file size # check_size() { local size=$1 local file=$2 local file_size=$(get_size $file) if [[ $size != $file_size ]] then fatal "error: wrong size ${file_size} != ${size}" fi } # # check_mode -- validate file mode # check_mode() { local mode=$1 local file=$2 local file_mode=$(get_mode $file) if [[ $mode != $file_mode ]] then fatal "error: wrong mode ${file_mode} != ${mode}" fi } # # check_signature -- check if file contains specified signature # check_signature() { local sig=$1 local file=$2 local file_sig=$($DD if=$file bs=1 count=$SIG_LEN 2>/dev/null | tr -d \\0) if [[ $sig != $file_sig ]] then fatal "error: $file: signature doesn't match ${file_sig} != ${sig}" fi } # # check_signatures -- check if multiple files contain specified signature # check_signatures() { local sig=$1 shift 1 for file in $* do check_signature $sig $file done } # # check_layout -- check if pmemobj pool contains specified layout # check_layout() { local layout=$1 local file=$2 local file_layout=$($DD if=$file bs=1\ skip=$LAYOUT_OFFSET count=$LAYOUT_LEN 2>/dev/null | tr -d \\0) if [[ $layout != $file_layout ]] then fatal "error: layout doesn't match ${file_layout} != ${layout}" fi } # # check_arena -- check if file contains specified arena signature # check_arena() { local file=$1 local sig=$($DD if=$file bs=1 skip=$ARENA_OFF count=$ARENA_SIG_LEN 2>/dev/null | tr -d \\0) if [[ $sig != $ARENA_SIG ]] then fatal "error: can't find arena signature" fi } # # dump_pool_info -- dump selected pool metadata and/or user data # function dump_pool_info() { # ignore selected header fields that differ by definition ${PMEMPOOL}.static-nondebug info $* | sed -e "/^UUID/,/^Checksum/d" } # # compare_replicas -- check replicas consistency by comparing `pmempool info` output # function compare_replicas() { disable_exit_on_error diff <(dump_pool_info $1 $2) <(dump_pool_info $1 $3) -I "^path" -I "^size" restore_exit_on_error } # # get_node_dir -- returns node dir for current test # usage: get_node_dir <node> # function get_node_dir() { validate_node_number $1 echo ${NODE_WORKING_DIR[$1]}/$curtestdir } # # init_rpmem_on_node -- prepare rpmem environment variables on node # usage: init_rpmem_on_node <master-node> <slave-node-1> [<slave-node-2> ...] # # example: # The following command initialize rpmem environment variables on the node 1 # to perform replication to node 0, node 2 and node 3. # Additionally: # - on node 2 rpmemd pid will be stored in file.pid # - on node 3 no pid file will be created (SKIP) and rpmemd will use # file.conf config file # # init_rpmem_on_node 1 0 2:file.pid 3:SKIP:file.conf # function init_rpmem_on_node() { local master=$1 shift validate_node_number $master case "$RPMEM_PM" in APM|GPSPM) ;; *) msg "$UNITTEST_NAME: SKIP required: RPMEM_PM is invalid or empty" exit 0 ;; esac # Workaround for SIGSEGV in the infinipath-psm during abort # The infinipath-psm is registering a signal handler and do not unregister # it when rpmem handle is dlclosed. SIGABRT (potentially any other signal) # would try to call the signal handler which does not exist after dlclose. # Issue require a fix in the infinipath-psm or the libfabric. IPATH_NO_BACKTRACE=1 export_vars_node $master IPATH_NO_BACKTRACE RPMEM_CMD="" local SEPARATOR="|" for slave in "$@" do slave=(${slave//:/ }) conf=${slave[2]} pid=${slave[1]} slave=${slave[0]} validate_node_number $slave local poolset_dir=${NODE_DIR[$slave]} if [ -n "${RPMEM_POOLSET_DIR[$slave]}" ]; then poolset_dir=${RPMEM_POOLSET_DIR[$slave]} fi local trace= if [ -n "$(is_valgrind_enabled_on_node $slave)" ]; then log_file=${CHECK_TYPE}${UNITTEST_NUM}.log trace=$(get_trace $CHECK_TYPE $log_file $slave) fi if [ -n "$pid" -a "$pid" != "SKIP" ]; then trace="$trace ../ctrld $pid exe" fi if [ -n ${UNITTEST_DO_NOT_CHECK_OPEN_FILES+x} ]; then export_vars_node $slave UNITTEST_DO_NOT_CHECK_OPEN_FILES fi if [ -n ${IPATH_NO_BACKTRACE+x} ]; then export_vars_node $slave IPATH_NO_BACKTRACE fi CMD="cd ${NODE_TEST_DIR[$slave]} && " # Force pmem for APM. Otherwise in case of lack of a pmem rpmemd will # silently fallback to GPSPM. [ "$RPMEM_PM" == "APM" ] && CMD="$CMD PMEM_IS_PMEM_FORCE=1" CMD="$CMD ${NODE_ENV[$slave]}" CMD="$CMD PATH=$REMOTE_PATH" CMD="$CMD LD_LIBRARY_PATH=${NODE_LD_LIBRARY_PATH[$slave]}:$REMOTE_LD_LIBRARY_PATH" CMD="$CMD $trace ../rpmemd" CMD="$CMD --log-file=$RPMEMD_LOG_FILE" CMD="$CMD --log-level=$RPMEMD_LOG_LEVEL" CMD="$CMD --poolset-dir=$poolset_dir" if [ -n "$conf" ]; then CMD="$CMD --config=$conf" fi if [ "$RPMEM_PM" == "APM" ]; then CMD="$CMD --persist-apm" fi if [ "$RPMEM_CMD" ]; then RPMEM_CMD="$RPMEM_CMD$SEPARATOR$CMD" else RPMEM_CMD=$CMD fi require_node_log_files $slave rpmemd$UNITTEST_NUM.log done RPMEM_CMD="\"$RPMEM_CMD\"" RPMEM_ENABLE_SOCKETS=0 RPMEM_ENABLE_VERBS=0 case "$RPMEM_PROVIDER" in sockets) RPMEM_ENABLE_SOCKETS=1 ;; verbs) RPMEM_ENABLE_VERBS=1 ;; *) msg "$UNITTEST_NAME: SKIP required: RPMEM_PROVIDER is invalid or empty" exit 0 ;; esac export_vars_node $master RPMEM_CMD export_vars_node $master RPMEM_ENABLE_SOCKETS export_vars_node $master RPMEM_ENABLE_VERBS if [ -n ${UNITTEST_DO_NOT_CHECK_OPEN_FILES+x} ]; then export_vars_node $master UNITTEST_DO_NOT_CHECK_OPEN_FILES fi if [ -n ${PMEMOBJ_NLANES+x} ]; then export_vars_node $master PMEMOBJ_NLANES fi if [ -n ${RPMEM_MAX_NLANES+x} ]; then export_vars_node $master RPMEM_MAX_NLANES fi require_node_log_files $master rpmem$UNITTEST_NUM.log require_node_log_files $master $PMEMOBJ_LOG_FILE } # # init_valgrind_on_node -- prepare valgrind on nodes # usage: init_valgrind_on_node <node list> # function init_valgrind_on_node() { # When librpmem is preloaded libfabric does not close all opened files # before list of opened files is checked. local UNITTEST_DO_NOT_CHECK_OPEN_FILES=1 local LD_PRELOAD=../$BUILD/librpmem.so CHECK_NODES="" for node in "$@" do validate_node_number $node export_vars_node $node LD_PRELOAD export_vars_node $node UNITTEST_DO_NOT_CHECK_OPEN_FILES CHECK_NODES="$CHECK_NODES $node" done } # # is_valgrind_enabled_on_node -- echo the node number if the node has # initialized valgrind environment by calling # init_valgrind_on_node # usage: is_valgrind_enabled_on_node <node> # function is_valgrind_enabled_on_node() { for node in $CHECK_NODES do if [ "$node" -eq "$1" ]; then echo $1 return fi done return } # # pack_all_libs -- put all libraries and their links to one tarball # function pack_all_libs() { local LIBS_TAR_DIR=$(pwd)/$1 cd $DIR_SRC tar -cf $LIBS_TAR_DIR ./debug/*.so* ./nondebug/*.so* cd - > /dev/null } # # copy_common_to_remote_nodes -- copy common files to all remote nodes # function copy_common_to_remote_nodes() { local NODES_ALL_MAX=$((${#NODE[@]} - 1)) local NODES_ALL_SEQ=$(seq -s' ' 0 $NODES_ALL_MAX) DIR_SYNC=$1 if [ "$DIR_SYNC" != "" ]; then [ ! -d $DIR_SYNC ] \ && fatal "error: $DIR_SYNC does not exist or is not a directory" fi # add all libraries to the 'to-copy' list local LIBS_TAR=libs.tar pack_all_libs $LIBS_TAR if [ "$DIR_SYNC" != "" -a "$(ls $DIR_SYNC)" != "" ]; then FILES_COMMON_DIR="$DIR_SYNC/* $LIBS_TAR" else FILES_COMMON_DIR="$FILES_COMMON_DIR $LIBS_TAR" fi for N in $NODES_ALL_SEQ; do # validate node's address [ "${NODE[$N]}" = "" ] \ && fatal "error: address of node #$N is not provided" check_if_node_is_reachable $N [ $? -ne 0 ] \ && msg "warning: node #$N (${NODE[$N]}) is unreachable, skipping..." \ && continue # validate the working directory [ "${NODE_WORKING_DIR[$N]}" = "" ] \ && msg ": warning: working directory for node #$N (${NODE[$N]}) is not provided, skipping..." \ && continue # create the working dir if it does not exist run_command ssh $SSH_OPTS ${NODE[$N]} "mkdir -p ${NODE_WORKING_DIR[$N]}" # copy all common files run_command scp $SCP_OPTS $FILES_COMMON_DIR ${NODE[$N]}:${NODE_WORKING_DIR[$N]} > /dev/null # unpack libraries run_command ssh $SSH_OPTS ${NODE[$N]} "cd ${NODE_WORKING_DIR[$N]} \ && tar -xf $LIBS_TAR && rm -f $LIBS_TAR" done rm -f $LIBS_TAR } # # copy_test_to_remote_nodes -- copy all unit test binaries to all remote nodes # function copy_test_to_remote_nodes() { local NODES_ALL_MAX=$((${#NODE[@]} - 1)) local NODES_ALL_SEQ=$(seq -s' ' 0 $NODES_ALL_MAX) for N in $NODES_ALL_SEQ; do # validate node's address [ "${NODE[$N]}" = "" ] \ && fatal "error: address of node #$N is not provided" check_if_node_is_reachable $N [ $? -ne 0 ] \ && msg "warning: node #$N (${NODE[$N]}) is unreachable, skipping..." \ && continue # validate the working directory [ "${NODE_WORKING_DIR[$N]}" = "" ] \ && msg ": warning: working directory for node #$N (${NODE[$N]}) is not provided, skipping..." \ && continue local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir # create a new test dir run_command ssh $SSH_OPTS ${NODE[$N]} "rm -rf $DIR && mkdir -p $DIR" # create the working data dir run_command ssh $SSH_OPTS ${NODE[$N]} "mkdir -p \ ${DIR}/data" # copy all required files [ $# -gt 0 ] && run_command scp $SCP_OPTS $* ${NODE[$N]}:$DIR > /dev/null done return 0 } # # enable_log_append -- turn on appending to the log files rather than truncating them # It also removes all log files created by tests: out*.log, err*.log and trace*.log # function enable_log_append() { rm -f $OUT_LOG_FILE rm -f $ERR_LOG_FILE rm -f $TRACE_LOG_FILE export UNITTEST_LOG_APPEND=1 } # clean data directory on all remote # nodes if remote test failed if [ "$CLEAN_FAILED_REMOTE" == "y" ]; then NODES_ALL=$((${#NODE[@]} - 1)) MYPID=$$ for ((i=0;i<=$NODES_ALL;i++)); do if [[ -z "${NODE_WORKING_DIR[$i]}" || -z "$curtestdir" ]]; then echo "Invalid path to tests data: ${NODE_WORKING_DIR[$i]}/$curtestdir/data/" exit 1 fi N[$i]=${NODE_WORKING_DIR[$i]}/$curtestdir/data/ run_command ssh $SSH_OPTS ${NODE[$i]} "rm -rf ${N[$i]}; mkdir ${N[$i]}" if [ $? -eq 0 ]; then verbose_msg "Removed data from: ${NODE[$i]}:${N[$i]}" fi done exit 0 fi # calculate the minimum of two or more numbers minimum() { local min=$1 shift for val in $*; do if [[ "$val" < "$min" ]]; then min=$val fi done echo $min } # # count_lines - count number of lines that match pattern $1 in file $2 # function count_lines() { # grep returns 1 on no match disable_exit_on_error $GREP -ce "$1" $2 restore_exit_on_error } # # get_pmemcheck_version() - return pmemcheck API major or minor version # usage: get_pmemcheck_version <0|1> # function get_pmemcheck_version() { PMEMCHECK_VERSION=$($VALGRINDEXE --tool=pmemcheck true 2>&1 \ | head -n 1 | sed "s/.*-\([0-9.]*\),.*/\1/") OIFS=$IFS IFS="." PMEMCHECK_MAJ_MIN=($PMEMCHECK_VERSION) IFS=$OIFS PMEMCHECK_VERSION_PART=${PMEMCHECK_MAJ_MIN[$1]} echo "$PMEMCHECK_VERSION_PART" } # # require_pmemcheck_version_ge - check if pmemcheck API # version is greater or equal to required value # usage: require_pmemcheck_version_ge <major> <minor> [binary] # function require_pmemcheck_version_ge() { require_valgrind_tool pmemcheck $3 REQUIRE_MAJOR=$1 REQUIRE_MINOR=$2 PMEMCHECK_MAJOR=$(get_pmemcheck_version 0) PMEMCHECK_MINOR=$(get_pmemcheck_version 1) # compare MAJOR if [ $PMEMCHECK_MAJOR -gt $REQUIRE_MAJOR ]; then return 0 fi # compare MINOR if [ $PMEMCHECK_MAJOR -eq $REQUIRE_MAJOR ]; then if [ $PMEMCHECK_MINOR -ge $REQUIRE_MINOR ]; then return 0 fi fi msg "$UNITTEST_NAME: SKIP pmemcheck API version:" \ "$PMEMCHECK_MAJOR.$PMEMCHECK_MINOR" \ "is less than required" \ "$REQUIRE_MAJOR.$REQUIRE_MINOR" exit 0 } # # require_pmemcheck_version_lt - check if pmemcheck API # version is less than required value # usage: require_pmemcheck_version_lt <major> <minor> [binary] # function require_pmemcheck_version_lt() { require_valgrind_tool pmemcheck $3 REQUIRE_MAJOR=$1 REQUIRE_MINOR=$2 PMEMCHECK_MAJOR=$(get_pmemcheck_version 0) PMEMCHECK_MINOR=$(get_pmemcheck_version 1) # compare MAJOR if [ $PMEMCHECK_MAJOR -lt $REQUIRE_MAJOR ]; then return 0 fi # compare MINOR if [ $PMEMCHECK_MAJOR -eq $REQUIRE_MAJOR ]; then if [ $PMEMCHECK_MINOR -lt $REQUIRE_MINOR ]; then return 0 fi fi msg "$UNITTEST_NAME: SKIP pmemcheck API version:" \ "$PMEMCHECK_MAJOR.$PMEMCHECK_MINOR" \ "is greater or equal than" \ "$REQUIRE_MAJOR.$REQUIRE_MINOR" exit 0 } # # require_python_3 -- check if python3 is available # function require_python3() { if hash python3 &>/dev/null; then PYTHON_EXE=python3 else PYTHON_EXE=python fi case "$($PYTHON_EXE --version 2>&1)" in *" 3."*) return ;; *) msg "$UNITTEST_NAME: SKIP: required python version 3" exit 0 ;; esac } # # require_pmreorder -- check all necessary conditions to run pmreorder # usage: require_pmreorder [binary] # function require_pmreorder() { # python3 and valgrind are necessary require_python3 # pmemcheck is required to generate store_log configure_valgrind pmemcheck force-enable $1 # pmreorder tool does not support unicode yet require_no_unicode } # # pmreorder_run_tool -- run pmreorder with parameters and return exit status # # 1 - reorder engine type [nochecker|full|noreorder|partial|accumulative] # 2 - marker-engine pairs in format: MARKER=ENGINE,MARKER1=ENGINE1 or # config file in json format: { "MARKER":"ENGINE","MARKER1":"ENGINE1" } # 3 - the path to the checker binary/library and remaining parameters which # will be passed to the consistency checker binary. # If you are using a library checker, prepend '-n funcname' # function pmreorder_run_tool() { rm -f pmreorder$UNITTEST_NUM.log disable_exit_on_error $PYTHON_EXE $PMREORDER \ -l store_log$UNITTEST_NUM.log \ -o pmreorder$UNITTEST_NUM.log \ -r $1 \ -x $2 \ -p "$3" ret=$? restore_exit_on_error echo $ret } # # pmreorder_expect_success -- run pmreoreder with forwarded parameters, # expect it to exit zero # function pmreorder_expect_success() { ret=$(pmreorder_run_tool "$@" | tail -n1) if [ "$ret" -ne "0" ]; then msg=$(interactive_red STDERR "failed with exit code $ret") # exit code 130 - script terminated by user (Control-C) if [ "$ret" -ne "130" ]; then echo -e "$UNITTEST_NAME $msg." >&2 dump_last_n_lines $PMREORDER_LOG_FILE fi false fi } # # pmreorder_expect_failure -- run pmreoreder with forwarded parameters, # expect it to exit non zero # function pmreorder_expect_failure() { ret=$(pmreorder_run_tool "$@" | tail -n1) if [ "$ret" -eq "0" ]; then msg=$(interactive_red STDERR "succeeded") echo -e "$UNITTEST_NAME command $msg unexpectedly." >&2 false fi } # # pmreorder_create_store_log -- perform a reordering test # # This function expects 5 additional parameters. They are in order: # 1 - the pool file to be tested # 2 - the application and necessary parameters to run pmemcheck logging # function pmreorder_create_store_log() { #copy original file and perform store logging cp $1 "$1.pmr" rm -f store_log$UNITTEST_NUM.log $VALGRINDEXE \ --tool=pmemcheck -q \ --log-stores=yes \ --print-summary=no \ --log-file=store_log$UNITTEST_NUM.log \ --log-stores-stacktraces=yes \ --log-stores-stacktraces-depth=2 \ --expect-fence-after-clflush=yes \ $2 # uncomment this line for debug purposes # mv $1 "$1.bak" mv "$1.pmr" $1 } # # require_free_space -- check if there is enough free space to run the test # Example, checking if there is 1 GB of free space on disk: # require_free_space 1G # function require_free_space() { req_free_space=$(convert_to_bytes $1) # actually require 5% or 8MB (whichever is higher) more, just in case # file system requires some space for its meta data pct=$((5 * $req_free_space / 100)) abs=$(convert_to_bytes 8M) if [ $pct -gt $abs ]; then req_free_space=$(($req_free_space + $pct)) else req_free_space=$(($req_free_space + $abs)) fi output=$(df -k $DIR) found=false i=1 for elem in $(echo "$output" | head -1); do if [ ${elem:0:5} == "Avail" ]; then found=true break else let "i+=1" fi done if [ $found = true ]; then row=$(echo "$output" | tail -1) free_space=$(( $(echo $row | awk "{print \$$i}")*1024 )) else msg "$UNITTEST_NAME: SKIP: unable to check free space" exit 0 fi if [ $free_space -lt $req_free_space ]; then msg "$UNITTEST_NAME: SKIP: not enough free space ($1 required)" exit 0 fi } # # require_max_devdax_size -- checks that dev dax is smaller than requested # # usage: require_max_devdax_size <dev-dax-num> <max-size> # function require_max_devdax_size() { cur_sz=$(get_devdax_size 0) max_size=$2 if [ $cur_sz -ge $max_size ]; then msg "$UNITTEST_NAME: SKIP: DevDAX $1 is too big for this test (max $2 required)" exit 0 fi } # # require_max_block_size -- checks that block size is smaller or equal than requested # # usage: require_max_block_size <file> <max-block-size> # function require_max_block_size() { cur_sz=$(stat --file-system --format=%S $1) max_size=$2 if [ $cur_sz -gt $max_size ]; then msg "$UNITTEST_NAME: SKIP: block size of $1 is too big for this test (max $2 required)" exit 0 fi } # # require_badblock_tests_enabled - check if tests for bad block support are not enabled # Input arguments: # 1) test device type # function require_badblock_tests_enabled() { require_sudo_allowed require_command ndctl require_bb_enabled_by_default $PMEMPOOL$EXESUFFIX if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then require_kernel_module nfit_test # nfit_test dax device is created by the test and is # used directly - no device dax path is needed to be provided by the # user. Some tests though may use an additional filesystem for the # pool replica - hence 'any' filesystem is required. if [ $1 == "dax_device" ]; then require_fs_type any # nfit_test block device is created by the test and mounted on # a filesystem of any type provided by the user elif [ $1 == "block_device" ]; then require_fs_type any fi elif [ "$BADBLOCK_TEST_TYPE" == "real_pmem" ]; then if [ $1 == "dax_device" ]; then require_fs_type any require_dax_devices 1 require_binary $DAXIO$EXESUFFIX elif [ $1 == "block_device" ]; then require_fs_type pmem fi else msg "$UNITTEST_NAME: SKIP: bad block tests are not enabled in testconfig.sh" exit 0 fi } # # require_badblock_tests_enabled_node - check if tests for bad block support are not enabled # on given remote node # function require_badblock_tests_enabled_node() { require_sudo_allowed_node $1 require_command_node $1 ndctl require_bb_enabled_by_default $PMEMPOOL$EXESUFFIX if [ "$BADBLOCK_TEST_TYPE" == "nfit_test" ]; then require_kernel_module_node $1 nfit_test elif [ "$BADBLOCK_TEST_TYPE" == "real_pmem" ]; then : else msg "$UNITTEST_NAME: SKIP: bad block tests are not enabled in testconfig.sh" exit 0 fi require_sudo_allowed require_kernel_module nfit_test require_command ndctl } # # create_recovery_file - create bad block recovery file # # Usage: create_recovery_file <file> [<offset_1> <length_1> ...] # # Offsets and length should be in page sizes. # function create_recovery_file() { [ $# -lt 1 ] && fatal "create_recovery_file(): not enough parameters: $*" FILE=$1 shift rm -f $FILE while [ $# -ge 2 ]; do OFFSET=$1 LENGTH=$2 shift 2 echo "$(($OFFSET * $PAGE_SIZE)) $(($LENGTH * $PAGE_SIZE))" >> $FILE done # write the finish flag echo "0 0" >> $FILE } # # zero_blocks - zero blocks in a file # # Usage: zero_blocks <file> <offset> <length> # # Offsets and length should be in page sizes. # function zero_blocks() { [ $# -lt 3 ] && fatal "zero_blocks(): not enough parameters: $*" FILE=$1 shift while [ $# -ge 2 ]; do OFFSET=$1 LENGTH=$2 shift 2 dd if=/dev/zero of=$FILE bs=$PAGE_SIZE seek=$OFFSET count=$LENGTH conv=notrunc status=none done } # # turn_on_checking_bad_blocks -- set the compat_feature POOL_FEAT_CHECK_BAD_BLOCKS on # function turn_on_checking_bad_blocks() { FILE=$1 expect_normal_exit "$PMEMPOOL feature -e CHECK_BAD_BLOCKS $FILE &>> $PREP_LOG_FILE" } # # turn_on_checking_bad_blocks_node -- set the compat_feature POOL_FEAT_CHECK_BAD_BLOCKS on # function turn_on_checking_bad_blocks_node() { FILE=$2 expect_normal_exit run_on_node $1 "../pmempool feature -e CHECK_BAD_BLOCKS $FILE &>> $PREP_LOG_FILE" }
95,035
23.943832
153
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/unittest/ut_pmem2_setup_integration.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2020, Intel Corporation */ /* * ut_pmem2_setup_integration.h -- libpmem2 setup functions using public API * (for integration tests) */ #ifndef UT_PMEM2_SETUP_INTEGRATION_H #define UT_PMEM2_SETUP_INTEGRATION_H 1 #include "ut_fh.h" /* a prepare_config() that can't set wrong value */ #define PMEM2_PREPARE_CONFIG_INTEGRATION(cfg, src, fd, g) \ ut_pmem2_prepare_config_integration( \ __FILE__, __LINE__, __func__, cfg, src, fd, g) void ut_pmem2_prepare_config_integration(const char *file, int line, const char *func, struct pmem2_config **cfg, struct pmem2_source **src, int fd, enum pmem2_granularity granularity); #endif /* UT_PMEM2_SETUP_INTEGRATION_H */
728
29.375
76
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_memblock/mocks_windows.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016, Intel Corporation */ /* * mocks_windows.h -- redefinitions of memops functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmemobj * files, when compiled for the purpose of obj_memblock test. * It would replace default implementation with mocked functions defined * in obj_memblock.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL #define operation_add_typed_entry __wrap_operation_add_typed_entry #define operation_add_entry __wrap_operation_add_entry #endif
634
29.238095
73
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_sds/mocks_windows.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2018-2020, Intel Corporation */ /* * mocks_windows.h -- redefinitions of dimm functions */ #ifndef WRAP_REAL #define pmem2_source_device_usc __wrap_pmem2_source_device_usc #define pmem2_source_device_idU __wrap_pmem2_source_device_id #endif
299
24
62
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/util_sds/mocks_windows.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2018-2020, Intel Corporation */ /* * mocks_windows.h -- redefinitions of dimm functions */ #ifndef WRAP_REAL #define pmem2_source_device_usc __wrap_pmem2_source_device_usc #define pmem2_source_device_idU __wrap_pmem2_source_device_id #endif
299
24
62
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_tx_add_range/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017, Intel Corporation # # # obj_tx_add_range/config.sh -- test configuration # # Extend timeout for this test, as it may take a few minutes # when run on a non-pmem file system. CONF_GLOBAL_TIMEOUT='10m'
281
19.142857
60
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmem_has_auto_flush_win/mocks_windows.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2018, Intel Corporation */ /* * mocks_windows.h -- redefinitions of EnumSystemFirmwareTables and * GetSystemFirmwareTable * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmem * files, when compiled for the purpose of pmem_has_auto_flush_win test. * It would replace default implementation with mocked functions defined * in mocks_windows.c * * This WRAP_REAL define could be also passed as preprocessor definition. */ #include <windows.h> #ifndef WRAP_REAL #define EnumSystemFirmwareTables __wrap_EnumSystemFirmwareTables #define GetSystemFirmwareTable __wrap_GetSystemFirmwareTable UINT __wrap_EnumSystemFirmwareTables(DWORD FirmwareTableProviderSignature, PVOID pFirmwareTableEnumBuffer, DWORD BufferSize); UINT __wrap_GetSystemFirmwareTable(DWORD FirmwareTableProviderSignature, DWORD FirmwareTableID, PVOID pFirmwareTableBuffer, DWORD BufferSize); #endif
988
33.103448
73
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmem_has_auto_flush_win/pmem_has_auto_flush_win.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2018, Intel Corporation */ /* * pmem_has_auto_flush_win.h -- header file for windows mocks * for pmem_has_auto_flush_win */ #ifndef PMDK_HAS_AUTO_FLUSH_WIN_H #define PMDK_HAS_AUTO_FLUSH_WIN_H 1 extern size_t Is_nfit; extern size_t Pc_type; extern size_t Pc_capabilities; #endif
338
20.1875
61
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/ex_librpmem_fibonacci/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019, Intel Corporation # # # ex_librpmem_fibonacci/config.sh -- test configuration # # Filesystem-DAX cannot be used for RDMA # since it is missing support in Linux kernel CONF_GLOBAL_FS_TYPE=non-pmem CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_TEST_TYPE=medium CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all CONF_TEST_TYPE[2]=long
431
20.6
55
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_heap_interrupt/mocks_windows.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2018, Intel Corporation */ /* * mocks_windows.h -- redefinitions of memops functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmemobj * files, when compiled for the purpose of obj_heap_interrupt test. * It would replace default implementation with mocked functions defined * in obj_heap_interrupt.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL #define operation_finish __wrap_operation_finish #endif
578
27.95
73
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_list/mocks_windows.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2018, Intel Corporation */ /* * mocks_windows.h -- redefinitions of obj list functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmemobj * files, when compiled for the purpose of obj_list test. * It would replace default implementation with mocked functions defined * in obj_list.c. * * These defines could be also passed as preprocessor definitions. */ #if defined(__cplusplus) extern "C" { #endif #ifdef WRAP_REAL #define WRAP_REAL_PMALLOC #define WRAP_REAL_ULOG #define WRAP_REAL_LANE #define WRAP_REAL_HEAP #define WRAP_REAL_PMEMOBJ #endif #ifndef WRAP_REAL_PMALLOC #define pmalloc __wrap_pmalloc #define pfree __wrap_pfree #define pmalloc_construct __wrap_pmalloc_construct #define prealloc __wrap_prealloc #define prealloc_construct __wrap_prealloc_construct #define palloc_usable_size __wrap_palloc_usable_size #define palloc_reserve __wrap_palloc_reserve #define palloc_publish __wrap_palloc_publish #define palloc_defer_free __wrap_palloc_defer_free #endif #ifndef WRAP_REAL_ULOG #define ulog_store __wrap_ulog_store #define ulog_process __wrap_ulog_process #endif #ifndef WRAP_REAL_LANE #define lane_hold __wrap_lane_hold #define lane_release __wrap_lane_release #define lane_recover_and_section_boot __wrap_lane_recover_and_section_boot #define lane_section_cleanup __wrap_lane_section_cleanup #endif #ifndef WRAP_REAL_HEAP #define heap_boot __wrap_heap_boot #endif #ifndef WRAP_REAL_PMEMOBJ #define pmemobj_alloc __wrap_pmemobj_alloc #define pmemobj_alloc_usable_size __wrap_pmemobj_alloc_usable_size #define pmemobj_openU __wrap_pmemobj_open #define pmemobj_close __wrap_pmemobj_close #define pmemobj_direct __wrap_pmemobj_direct #define pmemobj_pool_by_oid __wrap_pmemobj_pool_by_oid #define pmemobj_pool_by_ptr __wrap_pmemobj_pool_by_ptr #endif #if defined(__cplusplus) } #endif
1,933
26.628571
74
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_list/obj_list.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2018, Intel Corporation */ /* * obj_list.h -- unit tests for list module */ #include <stddef.h> #include <sys/param.h> #include "list.h" #include "obj.h" #include "lane.h" #include "unittest.h" #include "util.h" /* offset to "in band" item */ #define OOB_OFF (sizeof(struct oob_header)) /* pmemobj initial heap offset */ #define HEAP_OFFSET 8192 TOID_DECLARE(struct item, 0); TOID_DECLARE(struct list, 1); TOID_DECLARE(struct oob_list, 2); TOID_DECLARE(struct oob_item, 3); struct item { int id; POBJ_LIST_ENTRY(struct item) next; }; struct oob_header { char data[48]; }; struct oob_item { struct oob_header oob; struct item item; }; struct oob_list { struct list_head head; }; struct list { POBJ_LIST_HEAD(listhead, struct item) head; }; enum ulog_fail { /* don't fail at all */ NO_FAIL, /* fail after ulog_store */ FAIL_AFTER_FINISH, /* fail before ulog_store */ FAIL_BEFORE_FINISH, /* fail after process */ FAIL_AFTER_PROCESS }; /* global handle to pmemobj pool */ extern PMEMobjpool *Pop; /* pointer to heap offset */ extern uint64_t *Heap_offset; /* list lane section */ extern struct lane Lane; /* actual item id */ extern int *Id; /* fail event */ extern enum ulog_fail Ulog_fail; /* global "in band" lists */ extern TOID(struct list) List; extern TOID(struct list) List_sec; /* global "out of band" lists */ extern TOID(struct oob_list) List_oob; extern TOID(struct oob_list) List_oob_sec; extern TOID(struct oob_item) *Item; /* usage macros */ #define FATAL_USAGE()\ UT_FATAL("usage: obj_list <file> [PRnifr]") #define FATAL_USAGE_PRINT()\ UT_FATAL("usage: obj_list <file> P:<list>") #define FATAL_USAGE_PRINT_REVERSE()\ UT_FATAL("usage: obj_list <file> R:<list>") #define FATAL_USAGE_INSERT()\ UT_FATAL("usage: obj_list <file> i:<where>:<num>") #define FATAL_USAGE_INSERT_NEW()\ UT_FATAL("usage: obj_list <file> n:<where>:<num>:<value>") #define FATAL_USAGE_REMOVE_FREE()\ UT_FATAL("usage: obj_list <file> f:<list>:<num>:<from>") #define FATAL_USAGE_REMOVE()\ UT_FATAL("usage: obj_list <file> r:<num>") #define FATAL_USAGE_MOVE()\ UT_FATAL("usage: obj_list <file> m:<num>:<where>:<num>") #define FATAL_USAGE_FAIL()\ UT_FATAL("usage: obj_list <file> "\ "F:<after_finish|before_finish|after_process>")
2,314
21.475728
59
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/blk_rw_mt/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017, Intel Corporation # # # blk_rw_mt/config.sh -- test configuration # # Extend timeout for this test, as it may take a few minutes # when run on a non-pmem file system. CONF_GLOBAL_TIMEOUT='10m'
274
18.642857
60
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/ex_librpmem_hello/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019, Intel Corporation # # # ex_librpmem_hello/config.sh -- test configuration # # Filesystem-DAX cannot be used for RDMA # since it is missing support in Linux kernel CONF_GLOBAL_FS_TYPE=non-pmem CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_TEST_TYPE=short CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
402
21.388889
51
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/ex_librpmem_manpage/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019, Intel Corporation # # # ex_librpmem_manpage/config.sh -- test configuration # # Filesystem-DAX cannot be used for RDMA # since it is missing support in Linux kernel CONF_GLOBAL_FS_TYPE=non-pmem CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_TEST_TYPE=short CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
404
21.5
53
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_persist_count/mocks_windows.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2018, Intel Corporation */ /* * mocks_windows.h -- redefinitions of pmem functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmemobj * files, when compiled for the purpose of obj_persist_count test. * It would replace default implementation with mocked functions defined * in obj_persist_count.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL #define pmem_persist __wrap_pmem_persist #define pmem_flush __wrap_pmem_flush #define pmem_drain __wrap_pmem_drain #define pmem_msync __wrap_pmem_msync #define pmem_memcpy_persist __wrap_pmem_memcpy_persist #define pmem_memcpy_nodrain __wrap_pmem_memcpy_nodrain #define pmem_memcpy __wrap_pmem_memcpy #define pmem_memmove_persist __wrap_pmem_memmove_persist #define pmem_memmove_nodrain __wrap_pmem_memmove_nodrain #define pmem_memmove __wrap_pmem_memmove #define pmem_memset_persist __wrap_pmem_memset_persist #define pmem_memset_nodrain __wrap_pmem_memset_nodrain #define pmem_memset __wrap_pmem_memset #endif
1,130
34.34375
73
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/compat_incompat_features/common.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017-2019, Intel Corporation # # # compat_incompat_features/common.sh -- common stuff for compat/incompat feature # flags tests # ERR=err${UNITTEST_NUM}.log ERR_TEMP=err${UNITTEST_NUM}_part.log LOG=out${UNITTEST_NUM}.log LOG_TEMP=out${UNITTEST_NUM}_part.log rm -f $LOG && touch $LOG rm -f $LOG_TEMP && touch $LOG_TEMP rm -f $ERR && touch $ERR rm -f $ERR_TEMP && touch $ERR_TEMP LAYOUT=OBJ_LAYOUT$SUFFIX POOLSET=$DIR/pool.set POOL_TYPES=(obj blk log) # pmempool create arguments: declare -A create_args create_args[obj]="obj $POOLSET" create_args[blk]="blk 512 $POOLSET" create_args[log]="log $POOLSET" # Known compat flags: # Known incompat flags: let "POOL_FEAT_SINGLEHDR = 0x0001" let "POOL_FEAT_CKSUM_2K = 0x0002" let "POOL_FEAT_SDS = 0x0004" # Unknown compat flags: UNKNOWN_COMPAT=(2 4 8 1024) # Unknown incompat flags: UNKNOWN_INCOMPAT=(8 15 1111) # set compat flags in header set_compat() { local part=$1 local flag=$2 expect_normal_exit $PMEMSPOIL $part pool_hdr.features.compat=$flag \ "pool_hdr.f:checksum_gen" } # set incompat flags in header set_incompat() { local part=$1 local flag=$2 expect_normal_exit $PMEMSPOIL $part pool_hdr.features.incompat=$flag \ "pool_hdr.f:checksum_gen" }
1,326
22.280702
80
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/util_poolset/mocks_windows.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2017, Intel Corporation */ /* * mocks_windows.h -- redefinitions of libc functions used in util_poolset * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmem * files, when compiled for the purpose of util_poolset test. * It would replace default implementation with mocked functions defined * in util_poolset.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL_OPEN #define os_open __wrap_os_open #endif #ifndef WRAP_REAL_FALLOCATE #define os_posix_fallocate __wrap_os_posix_fallocate #endif #ifndef WRAP_REAL_PMEM #define pmem_is_pmem __wrap_pmem_is_pmem #endif
730
25.107143
74
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/util_poolset/mocks.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2015-2017, Intel Corporation */ #ifndef MOCKS_H #define MOCKS_H extern const char *Open_path; extern os_off_t Fallocate_len; extern size_t Is_pmem_len; #endif
216
17.083333
44
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_direct/obj_direct.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2017, Intel Corporation */ /* * obj_direct.h -- unit test for pmemobj_direct() */ #ifndef OBJ_DIRECT_H #define OBJ_DIRECT_H 1 #include "libpmemobj.h" void *obj_direct_inline(PMEMoid oid); void *obj_direct_non_inline(PMEMoid oid); #endif /* OBJ_DIRECT_H */
316
18.8125
49
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_defrag_advanced/pgraph.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2020, Intel Corporation */ /* * pgraph.h -- persistent graph representation */ #ifndef OBJ_DEFRAG_ADV_PGRAPH #define OBJ_DEFRAG_ADV_PGRAPH #include <libpmemobj/base.h> struct pgraph_params { unsigned graph_copies; }; struct pnode_t { unsigned node_id; unsigned edges_num; size_t pattern_size; size_t size; PMEMoid edges[]; }; struct pgraph_t { unsigned nodes_num; PMEMoid nodes[]; }; void pgraph_new(PMEMobjpool *pop, PMEMoid *oidp, struct vgraph_t *vgraph, struct pgraph_params *params, rng_t *rngp); void pgraph_delete(PMEMoid *oidp); void pgraph_print(struct pgraph_t *graph, const char *dump); #endif /* pgraph.h */
695
16.4
73
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_defrag_advanced/vgraph.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2020, Intel Corporation */ /* * vgraph.h -- volatile graph representation */ #ifndef OBJ_DEFRAG_ADV_VGRAPH #define OBJ_DEFRAG_ADV_VGRAPH #include "rand.h" struct vgraph_params { unsigned max_nodes; /* max # of nodes per graph */ unsigned max_edges; /* max # of edges per node */ /* # of nodes is between [max_nodes - range_nodes, max_nodes] */ unsigned range_nodes; /* # of edges is between [max_edges - range_edges, max_edges] */ unsigned range_edges; unsigned min_pattern_size; unsigned max_pattern_size; }; struct vnode_t { unsigned node_id; unsigned edges_num; /* # of edges starting from this node */ unsigned *edges; /* ids of nodes the edges are pointing to */ /* the persistent node attributes */ size_t pattern_size; /* size of the pattern allocated after the node */ size_t psize; /* the total size of the node */ }; struct vgraph_t { unsigned nodes_num; struct vnode_t node[]; }; unsigned rand_range(unsigned min, unsigned max, rng_t *rngp); struct vgraph_t *vgraph_new(struct vgraph_params *params, rng_t *rngp); void vgraph_delete(struct vgraph_t *graph); #endif
1,158
23.145833
72
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_tx_mt/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017, Intel Corporation # # # obj_tx_mt/config.sh -- test configuration # # Extend timeout for this test, as it may take a few minutes # when run on a non-pmem file system. CONF_GLOBAL_TIMEOUT='10m'
274
18.642857
60
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmem_map_file_win/mocks_windows.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2017, Intel Corporation */ /* * mocks_windows.h -- redefinitions of libc functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmem * files, when compiled for the purpose of pmem_map_file test. * It would replace default implementation with mocked functions defined * in pmem_map_file.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL #define os_posix_fallocate __wrap_os_posix_fallocate #define os_ftruncate __wrap_os_ftruncate #endif
608
28
72
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_rpmem_heap_state/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2017, Intel Corporation # # # obj_rpmem_heap_state/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=pmem CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
290
19.785714
54
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmem_addr_ext/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017, Intel Corporation # # # rpmem_addr_ext/config.sh -- test configuration file # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=sockets CONF_GLOBAL_RPMEM_PMETHOD=GPSPM
289
19.714286
53
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmem2_badblock_mocks/pmem2_badblock_mocks.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2020, Intel Corporation */ /* * pmem2_badblock_mocks.h -- definitions for pmem2_badblock_mocks test */ #include "extent.h" /* fd bits 6-8: type of device */ #define FD_REG_FILE (1 << 6) /* regular file */ #define FD_CHR_DEV (2 << 6) /* character device */ #define FD_DIRECTORY (3 << 6) /* directory */ #define FD_BLK_DEV (4 << 6) /* block device */ /* fd bits 4-5: ndctl mode */ #define MODE_NO_DEVICE (1 << 4) /* did not found any matching device */ #define MODE_NAMESPACE (2 << 4) /* namespace mode */ #define MODE_REGION (3 << 4) /* region mode */ /* fd bits 0-3: number of test */ /* masks */ #define MASK_DEVICE 0b0111000000 /* bits 6-8: device mask */ #define MASK_MODE 0b0000110000 /* bits 4-5: mode mask */ #define MASK_TEST 0b0000001111 /* bits 0-3: test mask */ /* checks */ #define IS_MODE_NO_DEVICE(x) ((x & MASK_MODE) == MODE_NO_DEVICE) #define IS_MODE_NAMESPACE(x) ((x & MASK_MODE) == MODE_NAMESPACE) #define IS_MODE_REGION(x) ((x & MASK_MODE) == MODE_REGION) /* default block size: 1kB */ #define BLK_SIZE_1KB 1024 /* default size of device: 1 GiB */ #define DEV_SIZE_1GB (1024 * 1024 * 1024) struct badblock *get_nth_hw_badblock(unsigned test, unsigned *i_bb); int get_extents(int fd, struct extents **exts);
1,290
31.275
71
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmemd_obc/setup.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2019, Intel Corporation # # src/test/rpmemd_obc/setup.sh -- common setup for rpmemd_obc tests # require_nodes 2 require_node_log_files 1 $RPMEM_LOG_FILE RPMEM_CMD="\"cd ${NODE_TEST_DIR[0]} && UNITTEST_FORCE_QUIET=1" RPMEM_CMD="$RPMEM_CMD RPMEMD_LOG_FILE=$RPMEMD_LOG_FILE" RPMEM_CMD="$RPMEM_CMD RPMEMD_LOG_LEVEL=$RPMEMD_LOG_LEVEL" RPMEM_CMD="$RPMEM_CMD LD_LIBRARY_PATH=${NODE_LD_LIBRARY_PATH[0]}:$REMOTE_LD_LIBRARY_PATH" RPMEM_CMD="$RPMEM_CMD ./rpmemd_obc$EXESUFFIX\"" export_vars_node 1 RPMEM_CMD
578
29.473684
89
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmemd_obc/rpmemd_obc_test_common.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2018, Intel Corporation */ /* * rpmemd_obc_test_common.h -- common declarations for rpmemd_obc test */ #include "unittest.h" #include "librpmem.h" #include "rpmem_proto.h" #include "rpmem_common.h" #include "rpmem_ssh.h" #include "rpmem_util.h" #include "rpmemd_log.h" #include "rpmemd_obc.h" #define PORT 1234 #define RKEY 0x0123456789abcdef #define RADDR 0xfedcba9876543210 #define PERSIST_METHOD RPMEM_PM_APM #define POOL_ATTR_INIT {\ .signature = "<RPMEM>",\ .major = 1,\ .compat_features = 2,\ .incompat_features = 3,\ .ro_compat_features = 4,\ .poolset_uuid = "POOLSET_UUID0123",\ .uuid = "UUID0123456789AB",\ .next_uuid = "NEXT_UUID0123456",\ .prev_uuid = "PREV_UUID0123456",\ .user_flags = "USER_FLAGS012345",\ } #define POOL_ATTR_ALT {\ .signature = "<ALT>",\ .major = 5,\ .compat_features = 6,\ .incompat_features = 7,\ .ro_compat_features = 8,\ .poolset_uuid = "UUID_POOLSET_ALT",\ .uuid = "ALT_UUIDCDEFFEDC",\ .next_uuid = "456UUID_NEXT_ALT",\ .prev_uuid = "UUID012_ALT_PREV",\ .user_flags = "012345USER_FLAGS",\ } #define POOL_SIZE 0x0001234567abcdef #define NLANES 0x123 #define NLANES_RESP 16 #define PROVIDER RPMEM_PROV_LIBFABRIC_SOCKETS #define POOL_DESC "pool.set" #define BUFF_SIZE 8192 static const char pool_desc[] = POOL_DESC; #define POOL_DESC_SIZE (sizeof(pool_desc) / sizeof(pool_desc[0])) struct rpmem_ssh *clnt_connect(char *target); void clnt_wait_disconnect(struct rpmem_ssh *ssh); void clnt_send(struct rpmem_ssh *ssh, const void *buff, size_t len); void clnt_recv(struct rpmem_ssh *ssh, void *buff, size_t len); void clnt_close(struct rpmem_ssh *ssh); enum conn_wait_close { CONN_CLOSE, CONN_WAIT_CLOSE, }; void set_rpmem_cmd(const char *fmt, ...); extern struct rpmemd_obc_requests REQ_CB; struct req_cb_arg { int resp; unsigned long long types; int force_ret; int ret; int status; }; static const struct rpmem_msg_hdr MSG_HDR = { .type = RPMEM_MSG_TYPE_CLOSE, .size = sizeof(struct rpmem_msg_hdr), }; static const struct rpmem_msg_create CREATE_MSG = { .hdr = { .type = RPMEM_MSG_TYPE_CREATE, .size = sizeof(struct rpmem_msg_create), }, .c = { .major = RPMEM_PROTO_MAJOR, .minor = RPMEM_PROTO_MINOR, .pool_size = POOL_SIZE, .nlanes = NLANES, .provider = PROVIDER, .buff_size = BUFF_SIZE, }, .pool_attr = POOL_ATTR_INIT, .pool_desc = { .size = POOL_DESC_SIZE, }, }; static const struct rpmem_msg_open OPEN_MSG = { .hdr = { .type = RPMEM_MSG_TYPE_OPEN, .size = sizeof(struct rpmem_msg_open), }, .c = { .major = RPMEM_PROTO_MAJOR, .minor = RPMEM_PROTO_MINOR, .pool_size = POOL_SIZE, .nlanes = NLANES, .provider = PROVIDER, .buff_size = BUFF_SIZE, }, .pool_desc = { .size = POOL_DESC_SIZE, }, }; static const struct rpmem_msg_close CLOSE_MSG = { .hdr = { .type = RPMEM_MSG_TYPE_CLOSE, .size = sizeof(struct rpmem_msg_close), }, }; static const struct rpmem_msg_set_attr SET_ATTR_MSG = { .hdr = { .type = RPMEM_MSG_TYPE_SET_ATTR, .size = sizeof(struct rpmem_msg_set_attr), }, .pool_attr = POOL_ATTR_ALT, }; TEST_CASE_DECLARE(server_accept_sim); TEST_CASE_DECLARE(server_accept_sim_fork); TEST_CASE_DECLARE(client_accept_sim); TEST_CASE_DECLARE(server_accept_seq); TEST_CASE_DECLARE(server_accept_seq_fork); TEST_CASE_DECLARE(client_accept_seq); TEST_CASE_DECLARE(client_bad_msg_hdr); TEST_CASE_DECLARE(server_bad_msg); TEST_CASE_DECLARE(server_msg_noresp); TEST_CASE_DECLARE(server_msg_resp); TEST_CASE_DECLARE(client_econnreset); TEST_CASE_DECLARE(server_econnreset); TEST_CASE_DECLARE(client_create); TEST_CASE_DECLARE(server_open); TEST_CASE_DECLARE(client_close); TEST_CASE_DECLARE(server_close); TEST_CASE_DECLARE(client_open); TEST_CASE_DECLARE(client_set_attr);
3,791
23
70
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmem2_memcpy/memcpy_common.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2020, Intel Corporation */ /* * memcpy_common.h -- header file for common memcpy utilities */ #ifndef MEMCPY_COMMON_H #define MEMCPY_COMMON_H 1 #include "unittest.h" #include "file.h" typedef void *(*memcpy_fn)(void *pmemdest, const void *src, size_t len, unsigned flags); typedef void (*persist_fn)(const void *ptr, size_t len); extern unsigned Flags[10]; void do_memcpy(int fd, char *dest, int dest_off, char *src, int src_off, size_t bytes, size_t mapped_len, const char *file_name, memcpy_fn fn, unsigned flags, persist_fn p); #endif
611
23.48
73
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_check_remote/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019, Intel Corporation # # # obj_check_remote/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_TEST_TYPE=medium CONF_GLOBAL_RPMEM_PROVIDER=sockets CONF_GLOBAL_RPMEM_PMETHOD=all
313
19.933333
50
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmempool_rm_remote/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017, Intel Corporation # # # pmempool_rm_remote/config.sh -- test configuration # set -e CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=sockets CONF_GLOBAL_RPMEM_PMETHOD=GPSPM
295
18.733333
52
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_rpmem_basic_integration/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2017, Intel Corporation # # # obj_rpmem_basic_integration/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=pmem CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_TEST_TYPE=medium CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all CONF_RPMEM_PROVIDER[9]=verbs CONF_RPMEM_PROVIDER[10]=verbs CONF_RPMEM_PROVIDER[11]=verbs CONF_RPMEM_PROVIDER[13]=verbs CONF_RPMEM_PROVIDER[14]=verbs CONF_RPMEM_PROVIDER[15]=verbs CONF_RPMEM_PROVIDER[16]=verbs CONF_RPMEM_PROVIDER[17]=verbs CONF_RPMEM_PROVIDER[18]=verbs CONF_RPMEM_VALGRIND[9]=y CONF_RPMEM_VALGRIND[10]=y CONF_RPMEM_VALGRIND[11]=y CONF_RPMEM_VALGRIND[13]=y CONF_RPMEM_VALGRIND[14]=y CONF_RPMEM_VALGRIND[15]=y CONF_RPMEM_VALGRIND[16]=y CONF_RPMEM_VALGRIND[17]=y CONF_RPMEM_VALGRIND[18]=y
830
22.742857
61
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmem_map_file/mocks_windows.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2016-2017, Intel Corporation */ /* * mocks_windows.h -- redefinitions of libc functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmem * files, when compiled for the purpose of pmem_map_file test. * It would replace default implementation with mocked functions defined * in pmem_map_file.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL #define os_posix_fallocate __wrap_os_posix_fallocate #define os_ftruncate __wrap_os_ftruncate #endif
608
28
72
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmem2_movnt_align/movnt_align_common.h
// SPDX-License-Identifier: BSD-3-Clause /* Copyright 2020, Intel Corporation */ /* * movnt_align_common.h -- header file for common movnt_align test utilities */ #ifndef MOVNT_ALIGN_COMMON_H #define MOVNT_ALIGN_COMMON_H 1 #include "unittest.h" #include "file.h" #define N_BYTES (Ut_pagesize * 2) extern char *Src; extern char *Dst; extern char *Scratch; extern unsigned Flags[10]; typedef void *(*mem_fn)(void *, const void *, size_t); typedef void *pmem_memcpy_fn(void *pmemdest, const void *src, size_t len, unsigned flags); typedef void *pmem_memmove_fn(void *pmemdest, const void *src, size_t len, unsigned flags); typedef void *pmem_memset_fn(void *pmemdest, int c, size_t len, unsigned flags); void check_memmove(size_t doff, size_t soff, size_t len, pmem_memmove_fn fn, unsigned flags); void check_memcpy(size_t doff, size_t soff, size_t len, pmem_memcpy_fn fn, unsigned flags); void check_memset(size_t off, size_t len, pmem_memset_fn fn, unsigned flags); #endif
989
26.5
80
h
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/obj_basic_integration/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017, Intel Corporation # # # obj_basic_integration/config.sh -- test configuration # # Extend timeout for this test, as it may take a few minutes # when run on a non-pmem file system. CONF_GLOBAL_TIMEOUT='10m'
286
19.5
60
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmempool_feature/common.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2018-2020, Intel Corporation # # src/test/pmempool_feature/common.sh -- common part of pmempool_feature tests # # for feature values please see: pmempool feature help PART_SIZE=$(convert_to_bytes 10M) # define files and directories POOLSET=$DIR/testset TEST_SET_LOCAL=testset_local TEST_SET_REMOTE=testset_remote LOG=grep${UNITTEST_NUM}.log pmempool_exe=$PMEMPOOL$EXESUFFIX exit_func=expect_normal_exit sds_enabled=$(is_ndctl_enabled $pmempool_exe; echo $?) # pmempool_feature_query -- query feature # # usage: pmempool_feature_query <feature> [<query-exit-type>] function pmempool_feature_query() { query_exit_type=${2-normal} query_exit_func=expect_${query_exit_type}_exit val=$($query_exit_func $pmempool_exe feature -q $1 $POOLSET 2>> $LOG) if [ "$query_exit_type" == "normal" ]; then echo "query $1 result is $val" &>> $LOG fi } # pmempool_feature_enable -- enable feature # # usage: pmempool_feature_enable <feature> [no-query] function pmempool_feature_enable() { $exit_func $pmempool_exe feature -e $1 $POOLSET &>> $LOG if [ "x$2" != "xno-query" ]; then pmempool_feature_query $1 fi } # pmempool_feature_disable -- disable feature # # usage: pmempool_feature_disable <feature> [no-query] function pmempool_feature_disable() { $exit_func $pmempool_exe feature -d $1 $POOLSET '&>>' $LOG if [ "x$2" != "xno-query" ]; then pmempool_feature_query $1 fi } # pmempool_feature_create_poolset -- create poolset # # usage: pmempool_feature_create_poolset <poolset-type> function pmempool_feature_create_poolset() { POOLSET_TYPE=$1 case "$1" in "no_dax_device") create_poolset $POOLSET \ $PART_SIZE:$DIR/testfile11:x \ $PART_SIZE:$DIR/testfile12:x \ r \ $PART_SIZE:$DIR/testfile21:x \ $PART_SIZE:$DIR/testfile22:x \ r \ $PART_SIZE:$DIR/testfile31:x ;; "dax_device") create_poolset $POOLSET \ AUTO:$DEVICE_DAX_PATH ;; "remote") create_poolset $DIR/$TEST_SET_LOCAL \ $PART_SIZE:${NODE_DIR[1]}/testfile_local11:x \ $PART_SIZE:${NODE_DIR[1]}/testfile_local12:x \ m ${NODE_ADDR[0]}:$TEST_SET_REMOTE create_poolset $DIR/$TEST_SET_REMOTE \ $PART_SIZE:${NODE_DIR[0]}/testfile_remote21:x \ $PART_SIZE:${NODE_DIR[0]}/testfile_remote22:x copy_files_to_node 0 ${NODE_DIR[0]} $DIR/$TEST_SET_REMOTE copy_files_to_node 1 ${NODE_DIR[1]} $DIR/$TEST_SET_LOCAL rm_files_from_node 1 \ ${NODE_DIR[1]}testfile_local11 ${NODE_DIR[1]}testfile_local12 rm_files_from_node 0 \ ${NODE_DIR[0]}testfile_remote21 ${NODE_DIR[0]}testfile_remote22 POOLSET="${NODE_DIR[1]}/$TEST_SET_LOCAL" ;; esac expect_normal_exit $pmempool_exe rm -f $POOLSET # create pool # pmempool create under valgrind pmemcheck takes too long # it is not part of the test so it is run here without valgrind VALGRIND_DISABLED=y expect_normal_exit $pmempool_exe create obj $POOLSET } # pmempool_feature_test_SINGLEHDR -- test SINGLEHDR function pmempool_feature_test_SINGLEHDR() { exit_func=expect_abnormal_exit pmempool_feature_enable "SINGLEHDR" "no-query" # UNSUPPORTED pmempool_feature_disable "SINGLEHDR" "no-query" # UNSUPPORTED exit_func=expect_normal_exit pmempool_feature_query "SINGLEHDR" } # pmempool_feature_test_CKSUM_2K -- test CKSUM_2K function pmempool_feature_test_CKSUM_2K() { # PMEMPOOL_FEAT_CHCKSUM_2K is enabled by default pmempool_feature_query "CKSUM_2K" # SHUTDOWN_STATE is disabled on Linux if PMDK is compiled with old ndctl # enable it to interfere toggling CKSUM_2K if [ $sds_enabled -eq 1 ]; then pmempool_feature_enable SHUTDOWN_STATE "no-query" fi # disable PMEMPOOL_FEAT_SHUTDOWN_STATE prior to success exit_func=expect_abnormal_exit pmempool_feature_disable "CKSUM_2K" # should fail exit_func=expect_normal_exit pmempool_feature_disable "SHUTDOWN_STATE" pmempool_feature_disable "CKSUM_2K" # should succeed pmempool_feature_enable "CKSUM_2K" } # pmempool_feature_test_SHUTDOWN_STATE -- test SHUTDOWN_STATE function pmempool_feature_test_SHUTDOWN_STATE() { pmempool_feature_query "SHUTDOWN_STATE" if [ $sds_enabled -eq 0 ]; then pmempool_feature_disable SHUTDOWN_STATE fi # PMEMPOOL_FEAT_SHUTDOWN_STATE requires PMEMPOOL_FEAT_CHCKSUM_2K pmempool_feature_disable "CKSUM_2K" exit_func=expect_abnormal_exit pmempool_feature_enable "SHUTDOWN_STATE" # should fail exit_func=expect_normal_exit pmempool_feature_enable "CKSUM_2K" pmempool_feature_enable "SHUTDOWN_STATE" # should succeed } # pmempool_feature_test_CHECK_BAD_BLOCKS -- test SHUTDOWN_STATE function pmempool_feature_test_CHECK_BAD_BLOCKS() { # PMEMPOOL_FEAT_CHECK_BAD_BLOCKS is disabled by default pmempool_feature_query "CHECK_BAD_BLOCKS" pmempool_feature_enable "CHECK_BAD_BLOCKS" pmempool_feature_disable "CHECK_BAD_BLOCKS" } # pmempool_feature_remote_init -- initialization remote replics function pmempool_feature_remote_init() { require_nodes 2 require_node_libfabric 0 $RPMEM_PROVIDER require_node_libfabric 1 $RPMEM_PROVIDER init_rpmem_on_node 1 0 pmempool_exe="run_on_node 1 ../pmempool" } # pmempool_feature_test_remote -- run remote tests function pmempool_feature_test_remote() { # create pool expect_normal_exit $pmempool_exe rm -f $POOLSET expect_normal_exit $pmempool_exe create obj $POOLSET # poolset with remote replicas are not supported exit_func=expect_abnormal_exit pmempool_feature_enable $1 no-query pmempool_feature_disable $1 no-query pmempool_feature_query $1 abnormal }
5,473
28.430108
78
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmempool_info_remote/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017, Intel Corporation # # # pmempool_info_remote/config.sh -- test configuration # set -e CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=sockets CONF_GLOBAL_RPMEM_PMETHOD=GPSPM
297
18.866667
54
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/ex_librpmem_basic/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2019, Intel Corporation # # # ex_librpmem_basic/config.sh -- test configuration # # Filesystem-DAX cannot be used for RDMA # since it is missing support in Linux kernel CONF_GLOBAL_FS_TYPE=non-pmem CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_TEST_TYPE=short CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
402
21.388889
51
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmempool_transform_remote/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017, Intel Corporation # # # pmempool_transform_remote/config.sh -- configuration of unit tests # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
298
20.357143
68
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmempool_transform_remote/common.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017-2018, Intel Corporation # # # pmempool_transform_remote/common.sh -- commons for pmempool transform tests # with remote replication # set -e require_nodes 2 require_node_libfabric 0 $RPMEM_PROVIDER require_node_libfabric 1 $RPMEM_PROVIDER setup init_rpmem_on_node 1 0 require_node_log_files 1 pmemobj$UNITTEST_NUM.log require_node_log_files 1 pmempool$UNITTEST_NUM.log LOG=out${UNITTEST_NUM}.log LOG_TEMP=out${UNITTEST_NUM}_part.log rm -f $LOG && touch $LOG rm -f $LOG_TEMP && touch $LOG_TEMP rm_files_from_node 0 ${NODE_TEST_DIR[0]}/$LOG rm_files_from_node 1 ${NODE_TEST_DIR[1]}/$LOG LAYOUT=OBJ_LAYOUT POOLSET_LOCAL_IN=poolset.in POOLSET_LOCAL_OUT=poolset.out POOLSET_REMOTE=poolset.remote POOLSET_REMOTE1=poolset.remote1 POOLSET_REMOTE2=poolset.remote2 # CLI scripts for writing and reading some data hitting all the parts WRITE_SCRIPT="pmemobjcli.write.script" READ_SCRIPT="pmemobjcli.read.script" copy_files_to_node 1 ${NODE_DIR[1]} $WRITE_SCRIPT $READ_SCRIPT DUMP_INFO_LOG="../pmempool info" DUMP_INFO_LOG_REMOTE="$DUMP_INFO_LOG -f obj" DUMP_INFO_SED="sed -e '/^Checksum/d' -e '/^Creation/d' -e '/^Previous replica UUID/d' -e '/^Next replica UUID/d'" DUMP_INFO_SED_REMOTE="$DUMP_INFO_SED -e '/^Previous part UUID/d' -e '/^Next part UUID/d'" function dump_info_log() { local node=$1 local poolset=$2 local name=$3 local ignore=$4 local sed_cmd="$DUMP_INFO_SED" if [ -n "$ignore" ]; then sed_cmd="$sed_cmd -e '/^$ignore/d'" fi expect_normal_exit run_on_node $node "\"$DUMP_INFO_LOG $poolset | $sed_cmd >> $name\"" } function dump_info_log_remote() { local node=$1 local poolset=$2 local name=$3 local ignore=$4 local sed_cmd="$DUMP_INFO_SED_REMOTE" if [ -n "$ignore" ]; then sed_cmd="$sed_cmd -e '/^$ignore/d'" fi expect_normal_exit run_on_node $node "\"$DUMP_INFO_LOG_REMOTE $poolset | $sed_cmd >> $name\"" } function diff_log() { local node=$1 local f1=$2 local f2=$3 expect_normal_exit run_on_node $node "\"[ -s $f1 ] && [ -s $f2 ] && diff $f1 $f2\"" } exec_pmemobjcli_script() { local node=$1 local script=$2 local poolset=$3 local out=$4 expect_normal_exit run_on_node $node "\"../pmemobjcli -s $script $poolset > $out \"" }
2,298
23.98913
113
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/pmempool_feature_remote/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2018, Intel Corporation # # # pmempool_feature_remote/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" # pmempool feature does not support poolsets with remote replicas # unittest contains only negative scenarios so no point to loop over # all providers and persistency methods CONF_GLOBAL_RPMEM_PROVIDER=sockets CONF_GLOBAL_RPMEM_PMETHOD=GPSPM
468
26.588235
68
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmem_basic/common_pm_policy.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2017-2018, Intel Corporation # # src/test/rpmem_basic/common_pm_policy.sh -- common part for TEST[10-11] scripts # set -e LOG=rpmemd$UNITTEST_NUM.log OUT=out$UNITTEST_NUM.log rm -f $OUT # create poolset and upload run_on_node 0 "rm -rf ${RPMEM_POOLSET_DIR[0]} && mkdir -p ${RPMEM_POOLSET_DIR[0]} && mkdir -p ${NODE_DIR[0]}$POOLS_PART" create_poolset $DIR/pool.set 8M:$PART_DIR/pool.part0 8M:$PART_DIR/pool.part1 copy_files_to_node 0 ${RPMEM_POOLSET_DIR[0]} $DIR/pool.set # create pool and close it - local pool from file SIMPLE_ARGS="test_create 0 pool.set ${NODE_ADDR[0]} pool 8M none test_close 0" function test_pm_policy() { # initialize pmem PMEM_IS_PMEM_FORCE=$1 export_vars_node 0 PMEM_IS_PMEM_FORCE init_rpmem_on_node 1 0 # remove rpmemd log and pool parts run_on_node 0 "rm -rf $PART_DIR && mkdir -p $PART_DIR && rm -f $LOG" # execute, get log expect_normal_exit run_on_node 1 ./rpmem_basic$EXESUFFIX $SIMPLE_ARGS copy_files_from_node 0 . ${NODE_TEST_DIR[0]}/$LOG # extract persist method and flush function cat $LOG | $GREP -A2 "persistency policy:" >> $OUT }
1,160
28.769231
120
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmem_basic/config.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2018, Intel Corporation # # # rpmem_basic/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all CONF_RPMEM_PMETHOD[10]=APM CONF_RPMEM_PMETHOD[11]=GPSPM # Sockets provider does not detect fi_cq_signal so it does not return # from fi_cq_sread. It causes this test to hang sporadically. # https://github.com/ofiwg/libfabric/pull/3645 CONF_RPMEM_PROVIDER[12]=verbs
547
23.909091
69
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmem_basic/setup2to1.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2017, Intel Corporation # # src/test/rpmem_basic/setup2to1.sh -- common part for TEST[7-] scripts # POOLS_DIR=pools POOLS_PART=pool_parts TEST_LOG_FILE=test$UNITTEST_NUM.log TEST_LOG_LEVEL=3 # # This unit test requires 4 nodes, but nodes #0 and #3 should be the same # physical machine - they should have the same NODE[n] addresses but # different NODE_ADDR[n] addresses in order to test "2-to-1" configuration. # Node #1 is being replicated to the node #0 and node #2 is being replicated # to the node #3. # require_nodes 4 REPLICA[1]=0 REPLICA[2]=3 for node in 1 2; do require_node_libfabric ${node} $RPMEM_PROVIDER require_node_libfabric ${REPLICA[${node}]} $RPMEM_PROVIDER export_vars_node ${node} TEST_LOG_FILE export_vars_node ${node} TEST_LOG_LEVEL require_node_log_files ${node} $PMEM_LOG_FILE require_node_log_files ${node} $RPMEM_LOG_FILE require_node_log_files ${node} $TEST_LOG_FILE require_node_log_files ${REPLICA[${node}]} $RPMEMD_LOG_FILE REP_ADDR[${node}]=${NODE_ADDR[${REPLICA[${node}]}]} PART_DIR[${node}]=${NODE_DIR[${REPLICA[${node}]}]}$POOLS_PART RPMEM_POOLSET_DIR[${REPLICA[${node}]}]=${NODE_DIR[${REPLICA[${node}]}]}$POOLS_DIR init_rpmem_on_node ${node} ${REPLICA[${node}]} PID_FILE[${node}]="pidfile${UNITTEST_NUM}-${node}.pid" clean_remote_node ${node} ${PID_FILE[${node}]} done
1,484
29.306122
82
sh
null
NearPMSW-main/nearpm/checkpointing/pmdk-checkpoint1/src/test/rpmem_basic/setup.sh
#!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause # Copyright 2016-2017, Intel Corporation # # src/test/rpmem_basic/setup.sh -- common part for TEST* scripts # set -e require_nodes 2 require_node_libfabric 0 $RPMEM_PROVIDER $SETUP_LIBFABRIC_VERSION require_node_libfabric 1 $RPMEM_PROVIDER $SETUP_LIBFABRIC_VERSION require_node_log_files 0 $RPMEMD_LOG_FILE require_node_log_files 1 $RPMEM_LOG_FILE require_node_log_files 1 $PMEM_LOG_FILE POOLS_DIR=pools POOLS_PART=pool_parts PART_DIR=${NODE_DIR[0]}/$POOLS_PART RPMEM_POOLSET_DIR[0]=${NODE_DIR[0]}$POOLS_DIR if [ -z "$SETUP_MANUAL_INIT_RPMEM" ]; then init_rpmem_on_node 1 0 fi
642
24.72
65
sh