Skip to content

Commit

Permalink
Rename test utility prefixes. (#291)
Browse files Browse the repository at this point in the history
Update common test infrastructure by avoiding the use of a qvi_ prefix.
Instead use ctu_ to avoid potential confusion with internal QV APIs.

Fixes #284.

Signed-off-by: Samuel K. Gutierrez <[email protected]>
  • Loading branch information
samuelkgutierrez authored Jan 9, 2025
1 parent 1b86b6a commit 8e2fe36
Show file tree
Hide file tree
Showing 17 changed files with 332 additions and 332 deletions.
6 changes: 3 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*-
#
# Copyright (c) 2020-2024 Triad National Security, LLC
# Copyright (c) 2020-2025 Triad National Security, LLC
# All rights reserved.
#
# Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC
Expand Down Expand Up @@ -82,7 +82,7 @@ endif()
if(MPI_FOUND)
add_executable(
test-mpi-init
qvi-test-common.h
common-test-utils.h
test-mpi-init.c
)

Expand Down Expand Up @@ -144,7 +144,7 @@ if(MPI_FOUND)

add_executable(
test-pthread-split
qvi-test-common.h
common-test-utils.h
test-pthread-split.c
)

Expand Down
72 changes: 36 additions & 36 deletions tests/qvi-test-common.h → tests/common-test-utils.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2020-2023 Triad National Security, LLC
* Copyright (c) 2020-2025 Triad National Security, LLC
* All rights reserved.
*
* This file is part of the quo-vadis project. See the LICENSE file at the
* top-level directory of this distribution.
*/

/**
* @file qvi-test-common.h
* @file common-test-utils.h
*
* Common test infrastructure.
*/
Expand All @@ -28,10 +28,10 @@
#include <sys/syscall.h>
#include <unistd.h>

#define QVI_TEST_STRINGIFY(x) #x
#define QVI_TEST_TOSTRING(x) QVI_TEST_STRINGIFY(x)
#define CTU_STRINGIFY(x) #x
#define CTU_TOSTRING(x) CTU_STRINGIFY(x)

#define qvi_test_panic(...) \
#define ctu_panic(...) \
do { \
fprintf(stderr, "\n%s@%d: ", __func__, __LINE__); \
fprintf(stderr, __VA_ARGS__); \
Expand All @@ -44,49 +44,49 @@ do { \
#ifdef QUO_VADIS

static inline pid_t
qvi_test_gettid(void)
ctu_gettid(void)
{
return (pid_t)syscall(SYS_gettid);
}

static inline void
qvi_test_emit_task_bind(
ctu_emit_task_bind(
qv_scope_t *scope
) {
const int pid = qvi_test_gettid();
const int pid = ctu_gettid();
char const *ers = NULL;
// Get new, current binding.
char *binds = NULL;
int rc = qv_scope_bind_string(scope, QV_BIND_STRING_AS_LIST, &binds);
if (rc != QV_SUCCESS) {
ers = "qv_bind_string() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
printf("[%d] cpubind=%s\n", pid, binds);
free(binds);
}

static inline void
qvi_test_scope_report(
ctu_scope_report(
qv_scope_t *scope,
const char *const scope_name
) {
char const *ers = NULL;

const int pid = qvi_test_gettid();
const int pid = ctu_gettid();

int sgrank;
int rc = qv_scope_group_rank(scope, &sgrank);
if (rc != QV_SUCCESS) {
ers = "qv_scope_group_rank() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}

int sgsize;
rc = qv_scope_group_size(scope, &sgsize);
if (rc != QV_SUCCESS) {
ers = "qv_scope_group_size() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}

printf(
Expand All @@ -99,48 +99,48 @@ qvi_test_scope_report(
rc = qv_scope_barrier(scope);
if (rc != QV_SUCCESS) {
ers = "qv_scope_barrier() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
}

/**
* A verbose version of qv_bind_push().
*/
static inline void
qvi_test_bind_push(
ctu_bind_push(
qv_scope_t *scope
) {
char const *ers = NULL;
const int pid = qvi_test_gettid();
const int pid = ctu_gettid();

int sgrank;
int rc = qv_scope_group_rank(scope, &sgrank);
if (rc != QV_SUCCESS) {
ers = "qv_scope_group_rank() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
// Get current binding.
char *bind0s;
rc = qv_scope_bind_string(scope, QV_BIND_STRING_AS_LIST, &bind0s);
if (rc != QV_SUCCESS) {
ers = "qv_bind_string() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
printf("[%d] Current cpubind before qv_bind_push() is %s\n", pid, bind0s);

// Change binding.
rc = qv_scope_bind_push(scope);
if (rc != QV_SUCCESS) {
ers = "qv_bind_push() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}

// Get new, current binding.
char *bind1s;
rc = qv_scope_bind_string(scope, QV_BIND_STRING_AS_LIST, &bind1s);
if (rc != QV_SUCCESS) {
ers = "qv_bind_string() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
printf("[%d] New cpubind after qv_bind_push() is %s\n", pid, bind1s);

Expand All @@ -152,40 +152,40 @@ qvi_test_bind_push(
* A verbose version of qv_bind_pop().
*/
static inline void
qvi_test_bind_pop(
ctu_bind_pop(
qv_scope_t *scope
) {
char const *ers = NULL;

const int pid = qvi_test_gettid();
const int pid = ctu_gettid();

int sgrank;
int rc = qv_scope_group_rank(scope, &sgrank);
if (rc != QV_SUCCESS) {
ers = "qv_scope_group_rank() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
// Get current binding.
char *bind0s;
rc = qv_scope_bind_string(scope, QV_BIND_STRING_AS_LIST, &bind0s);
if (rc != QV_SUCCESS) {
ers = "qv_bind_string() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
printf("[%d] Current cpubind before qv_bind_pop() is %s\n", pid, bind0s);

// Change binding.
rc = qv_scope_bind_pop(scope);
if (rc != QV_SUCCESS) {
ers = "qv_bind_push() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
// Get new, current binding.
char *bind1s;
rc = qv_scope_bind_string(scope, QV_BIND_STRING_AS_LIST, &bind1s);
if (rc != QV_SUCCESS) {
ers = "qv_bind_string() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
printf("[%d] New cpubind after qv_bind_pop() is %s\n", pid, bind1s);

Expand All @@ -198,61 +198,61 @@ qvi_test_bind_pop(
* binding policies.
*/
static inline void
qvi_test_change_bind(
ctu_change_bind(
qv_scope_t *scope
) {
char const *ers = NULL;

const int pid = qvi_test_gettid();
const int pid = ctu_gettid();

int sgrank;
int rc = qv_scope_group_rank(scope, &sgrank);
if (rc != QV_SUCCESS) {
ers = "qv_scope_group_rank() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
// Get current binding.
char *bind0s;
rc = qv_scope_bind_string(scope, QV_BIND_STRING_AS_LIST, &bind0s);
if (rc != QV_SUCCESS) {
ers = "qv_bind_string() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
printf("[%d] Current cpubind is %s\n", pid, bind0s);

// Change binding.
rc = qv_scope_bind_push(scope);
if (rc != QV_SUCCESS) {
ers = "qv_bind_push() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}

// Get new, current binding.
char *bind1s;
rc = qv_scope_bind_string(scope, QV_BIND_STRING_AS_LIST, &bind1s);
if (rc != QV_SUCCESS) {
ers = "qv_bind_string() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
printf("[%d] New cpubind is %s\n", pid, bind1s);

rc = qv_scope_bind_pop(scope);
if (rc != QV_SUCCESS) {
ers = "qv_bind_pop() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}

char *bind2s;
rc = qv_scope_bind_string(scope, QV_BIND_STRING_AS_LIST, &bind2s);
if (rc != QV_SUCCESS) {
ers = "qv_bind_string() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
printf("[%d] Popped cpubind is %s\n", pid, bind2s);

if (strcmp(bind0s, bind2s)) {
ers = "bind push/pop mismatch";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}

free(bind0s);
Expand All @@ -262,7 +262,7 @@ qvi_test_change_bind(
rc = qv_scope_barrier(scope);
if (rc != QV_SUCCESS) {
ers = "qv_scope_barrier() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
ctu_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
}

Expand Down
Loading

0 comments on commit 8e2fe36

Please sign in to comment.