• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LLNL / dftracer / 2760

02 Dec 2025 05:20AM UTC coverage: 38.87% (+9.8%) from 29.083%
2760

push

github

web-flow
Merge f1f0c2140 into 4ef0a645e

3634 of 12986 branches covered (27.98%)

Branch coverage included in aggregate %.

894 of 962 new or added lines in 7 files covered. (92.93%)

6 existing lines in 1 file now uncovered.

3085 of 4300 relevant lines covered (71.74%)

1001.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.39
/test/cpp/test_cpp_api_coverage.cpp
1
//
2
// Comprehensive C++ API Coverage Test
3
// Tests all C++ API functions provided by dftracer
4
//
5

6
#include <dftracer/dftracer.h>
7
#include <fcntl.h>
8
#include <sys/stat.h>
9
#include <unistd.h>
10

11
#include <cstdio>
12
#include <cstring>
13

14
// Test all function-level tracing APIs
15
void test_function_tracing() {
1✔
16
  DFTRACER_CPP_FUNCTION();
1✔
17

18
  // Test function metadata updates
19
  DFTRACER_CPP_FUNCTION_UPDATE("int_key", 42);
1✔
20
  DFTRACER_CPP_FUNCTION_UPDATE("string_key", "test_value");
1✔
21
  DFTRACER_CPP_FUNCTION_UPDATE("double_key", 3.14);
1✔
22

23
  usleep(1000);
1✔
24
}
1✔
25

26
// Test region-based tracing APIs
27
void test_region_tracing() {
1✔
28
  DFTRACER_CPP_FUNCTION();
1✔
29

30
  // Static region
31
  {
32
    DFTRACER_CPP_REGION(STATIC_REGION);
1✔
33
    DFTRACER_CPP_REGION_UPDATE(STATIC_REGION, "region_key", "region_value");
1✔
34
    DFTRACER_CPP_REGION_UPDATE(STATIC_REGION, "region_int", 100);
1✔
35
    usleep(500);
1✔
36
  }
1✔
37

38
  // Dynamic region with start/end
39
  DFTRACER_CPP_REGION_START(DYNAMIC_REGION);
1✔
40
  DFTRACER_CPP_REGION_DYN_UPDATE(DYNAMIC_REGION, "dyn_key", 200);
1✔
41
  DFTRACER_CPP_REGION_DYN_UPDATE(DYNAMIC_REGION, "dyn_str", "dynamic");
1✔
42
  usleep(500);
1✔
43
  DFTRACER_CPP_REGION_END(DYNAMIC_REGION);
1!
44

45
  // Nested regions
46
  {
47
    DFTRACER_CPP_REGION(OUTER_REGION);
1✔
48
    usleep(200);
1✔
49
    {
50
      DFTRACER_CPP_REGION(INNER_REGION);
1✔
51
      usleep(200);
1✔
52
    }
1✔
53
  }
1✔
54
}
1✔
55

56
// Test metadata APIs
57
void test_metadata() {
1✔
58
  DFTRACER_CPP_FUNCTION();
1✔
59

60
  DFTRACER_CPP_METADATA(global_meta, "app_name", "api_coverage_test");
1✔
61
  DFTRACER_CPP_METADATA(version_meta, "version", "1.0.0");
1✔
62
  DFTRACER_CPP_METADATA(config_meta, "config", "test_mode");
1✔
63
}
1✔
64

65
// Test I/O tracing with POSIX calls
66
void test_io_operations(const char* data_dir) {
1✔
67
  DFTRACER_CPP_FUNCTION();
1✔
68

69
  char filename[1024];
70
  snprintf(filename, sizeof(filename), "%s/cpp_api_test.dat", data_dir);
1✔
71

72
  // File operations
73
  int fd = open(filename, O_CREAT | O_RDWR, 0644);
1✔
74
  if (fd != -1) {
1!
75
    char buf[128] = "test data";
1✔
76
    write(fd, buf, strlen(buf));
1✔
77
    lseek(fd, 0, SEEK_SET);
1✔
78
    read(fd, buf, sizeof(buf));
1✔
79
    fsync(fd);
1✔
80
    close(fd);
1✔
81
  }
82

83
  // FILE* operations
84
  FILE* fp = fopen(filename, "r+");
1✔
85
  if (fp != nullptr) {
1!
86
    char buf[128];
87
    fwrite("more data", 1, 9, fp);
1✔
88
    fseek(fp, 0, SEEK_SET);
1✔
89
    fread(buf, 1, sizeof(buf), fp);
1✔
90
    fflush(fp);
1✔
91
    fclose(fp);
1✔
92
  }
93

94
  // File metadata operations
95
  struct stat st;
96
  stat(filename, &st);
1✔
97
  chmod(filename, 0600);
1✔
98

99
  // Cleanup
100
  unlink(filename);
1✔
101
}
1✔
102

103
int main(int argc, char* argv[]) {
1✔
104
  if (argc < 2) {
1!
NEW
105
    fprintf(stderr, "Usage: %s <data_dir>\n", argv[0]);
×
NEW
106
    return 1;
×
107
  }
108

109
  // Initialize DFTracer
110
  DFTRACER_CPP_INIT(nullptr, nullptr, nullptr);
1✔
111

112
  // Run all test functions
113
  test_metadata();
1✔
114
  test_function_tracing();
1✔
115
  test_region_tracing();
1✔
116
  test_io_operations(argv[1]);
1✔
117

118
  // Finalize
119
  DFTRACER_CPP_FINI();
1✔
120

121
  return 0;
1✔
122
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc