Skip to content

Commit

Permalink
DAOS-12710 build: Add unit testing that header can be included.
Browse files Browse the repository at this point in the history
Add a unit test to verify all installed headers can be included
standalone.

Remove scons check for cart and gurt headers for the same.

Required-githooks: true

Signed-off-by: Ashley Pittman <[email protected]>
  • Loading branch information
ashleypittman committed Jan 16, 2024
1 parent 217aab9 commit 2eb2a3d
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 30 deletions.
14 changes: 0 additions & 14 deletions site_scons/site_tools/extra/extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,6 @@ def _preprocess_emitter(source, target, env):
return target, source


def _ch_emitter(source, target, **_kw):
"""generate target list for check header builder"""
target = []
for src in source:
(base, _ext) = os.path.splitext(src.abspath)
target.append(f"{base}_check_header$OBJSUFFIX")
return target, source


def main():
"""Check for a supported version of clang-format"""
supported = _supports_correct_style(WhereIs('clang-format'))
Expand Down Expand Up @@ -136,15 +127,10 @@ def _pp_gen(source, target, env, for_signature):

# Only handle C for now
preprocess = Builder(generator=_pp_gen, emitter=_preprocess_emitter)
# Workaround for SCons issue #2757. Avoid using Configure for internal headers
check_header = Builder(action='$CCCOM', emitter=_ch_emitter)

if not env["BUILDERS"].get("Preprocess", False):
env.Append(BUILDERS={"Preprocess": preprocess})

if not env["BUILDERS"].get("CheckHeader", False):
env.Append(BUILDERS={"CheckHeader": check_header})


def exists(_env):
"""assert existence of tool"""
Expand Down
19 changes: 6 additions & 13 deletions src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ HEADERS = ['daos_api.h', 'daos_types.h', 'daos_errno.h', 'daos_kv.h',
'daos_event.h', 'daos_mgmt.h', 'daos_types.h', 'daos_array.h',
'daos_task.h', 'daos_fs.h', 'daos_uns.h', 'daos_security.h',
'daos_prop.h', 'daos_obj_class.h', 'daos_obj.h', 'daos_pool.h',
'daos_cont.h', 'daos_version.h', 'daos_fs_sys.h', 'daos_s3.h', 'daos_pipeline.h']
'daos_cont.h', 'daos_version.h', 'daos_fs_sys.h', 'daos_s3.h', 'daos_pipeline.h',
'daos.h']
HEADERS_GURT = ['dlog.h', 'debug.h', 'common.h', 'hash.h', 'list.h',
'heap.h', 'fault_inject.h', 'debug_setup.h',
'types.h', 'atomic.h', 'slab.h',
Expand Down Expand Up @@ -54,15 +55,6 @@ def read_and_save_version(env):
return version


def check_install_header(env, header):
"""Runs a builder to ensure the header can standalone compile and installs it"""
result = env.CheckHeader(header)
# Ensure the target, actually gets built since none of these targets
# get installed.
Default(result)
env.Install(os.path.join('$PREFIX', os.path.dirname(header)), header)


def scons():
"""Execute build"""
Import('env', 'base_env', 'base_env_mpi', 'prereqs')
Expand Down Expand Up @@ -94,10 +86,11 @@ def scons():
for header in HEADERS:
env.Install(os.path.join('$PREFIX', 'include'), os.path.join('include', header))
for header in HEADERS_GURT:
check_install_header(env, os.path.join('include', 'gurt', header))
env.Install(os.path.join("$PREFIX", "include", "gurt"),
os.path.join("include", "gurt", header))
for header in HEADERS_CART:
check_install_header(env, os.path.join('include', 'cart', header))
check_install_header(env, 'include/daos.h')
env.Install(os.path.join("$PREFIX", "include", "cart"),
os.path.join("include", "cart", header))

env.Append(CCFLAGS=['-DCART_VERSION=\\"' + CART_VERSION + '\\"'])
libdaos_tgts = []
Expand Down
2 changes: 2 additions & 0 deletions src/include/daos_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
extern "C" {
#endif

#include <daos_types.h>

/** Flags for daos_tx_open */
enum {
/** The transaction is read only. */
Expand Down
4 changes: 4 additions & 0 deletions src/include/daos_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
extern "C" {
#endif

#include <daos_types.h>
#include <daos_obj.h>
#include <daos_obj_class.h>

/** Range of contiguous records */
typedef struct {
/** Index of the first record in the range */
Expand Down
7 changes: 7 additions & 0 deletions src/include/daos_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ extern "C" {
#endif

#include <dirent.h>
#include <inttypes.h>
#include <sys/stat.h>

#include <daos_types.h>
#include <daos_obj.h>
#include <daos_obj_class.h>
#include <daos_array.h>
#include <daos_cont.h>

/** Maximum Name length */
#define DFS_MAX_NAME NAME_MAX
/** Maximum PATH length */
Expand Down
3 changes: 3 additions & 0 deletions src/include/daos_kv.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
extern "C" {
#endif

#include <daos_types.h>
#include <daos_obj.h>

/** Conditional Op: Insert key if it doesn't exist, fail otherwise */
#define DAOS_COND_KEY_INSERT DAOS_COND_DKEY_INSERT
/** Conditional Op: Update key if it exists, fail otherwise */
Expand Down
4 changes: 1 addition & 3 deletions src/include/daos_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ extern "C" {

#include <uuid/uuid.h>

#include <daos_event.h>
#include <daos_types.h>
#include <daos_pool.h>
#include <daos_cont.h>

/**
* Get the DAOS system information in a newly allocated structure.
Expand Down
5 changes: 5 additions & 0 deletions src/include/daos_obj_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
extern "C" {
#endif

#include <sys/types.h>
#include <inttypes.h>

#include <daos_types.h>

#define MAX_OBJ_CLASS_NAME_LEN 24

#define MAX_NUM_GROUPS ((1 << 16UL) - 1)
Expand Down
5 changes: 5 additions & 0 deletions src/include/daos_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
extern "C" {
#endif

#include <inttypes.h>
#include <uuid/uuid.h>

#include <daos_prop.h>

/** Type of storage target */
typedef enum {
DAOS_TP_UNKNOWN,
Expand Down
1 change: 1 addition & 0 deletions src/include/daos_prop.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extern "C" {
#endif

#include <ctype.h>

#include <daos_types.h>

/**
Expand Down
4 changes: 4 additions & 0 deletions src/include/daos_uns.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
extern "C" {
#endif

#include <daos_prop.h>
#include <daos_obj_class.h>
#include <daos_cont.h>

/** Flags for duns_resolve_path */
enum {
/*
Expand Down
4 changes: 4 additions & 0 deletions utils/utest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# (C) Copyright 2023 Intel Corporation.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
- name: Include checks
base: "BUILD_DIR"
tests:
- cmd: ["utils/include_test.py"]
- name: common
base: "BUILD_DIR"
tests:
Expand Down

0 comments on commit 2eb2a3d

Please sign in to comment.