MCPcopy
hub / github.com/tanelpoder/0xtools / XtopTestRunner

Class XtopTestRunner

xtop/tests/test_runner.py:119–390  ·  view source on GitHub ↗

Main test runner for XTOP

Source from the content-addressed store, hash-verified

117
118
119class XtopTestRunner:
120 """Main test runner for XTOP"""
121
122 def __init__(self, verbose: bool = False):
123 self.verbose = verbose
124 self.suites: List[TestSuite] = []
125 self.datadir = os.environ.get('XCAPTURE_DATADIR', '/home/tanel/dev/0xtools-next/xcapture/out')
126 self.from_time = "2025-08-11T16:25:00"
127 self.to_time = "2025-08-11T17:05:00"
128
129 # Check if data directory exists
130 if not Path(self.datadir).exists():
131 print(f"{YELLOW}Warning: Data directory not found: {self.datadir}{RESET}")
132 print(f"Set XCAPTURE_DATADIR environment variable to point to xcapture output")
133
134 def create_basic_suite(self) -> TestSuite:
135 """Create basic functionality test suite"""
136 suite = TestSuite("Basic Tests", "Core functionality tests")
137
138 # Base command template
139 base_cmd = f"python3 ../xtop-test.py -d {self.datadir} --from '{self.from_time}' --to '{self.to_time}'"
140
141 tests = [
142 ("basic_query", "Basic dynamic query",
143 f"{base_cmd} --limit 5 --format simple"),
144
145 ("group_by", "GROUP BY columns",
146 f"{base_cmd} -g 'state,username,comm' --limit 5 --format simple"),
147
148 ("computed_cols", "Computed columns",
149 f"{base_cmd} -g 'state,filenamesum,comm2' --limit 5 --format simple"),
150
151 ("where_clause", "WHERE clause filtering",
152 f"{base_cmd} -g 'state,comm' -w \"state IN ('SLEEP', 'RUN')\" --limit 5 --format simple"),
153
154 ("time_columns", "Time bucket columns",
155 f"{base_cmd} -g 'HH,MI,state' --limit 5 --format simple"),
156 ]
157
158 for name, desc, cmd in tests:
159 suite.add_test(TestCase(name, desc, cmd))
160
161 return suite
162
163 def create_latency_suite(self) -> TestSuite:
164 """Create latency analysis test suite"""
165 suite = TestSuite("Latency Tests", "Latency analysis functionality")
166
167 base_cmd = f"python3 ../xtop-test.py -d {self.datadir} --from '{self.from_time}' --to '{self.to_time}'"
168
169 tests = [
170 ("syscall_latency", "System call latency percentiles",
171 f"{base_cmd} -g 'state,syscall' -l 'sc.p50_us,sc.p95_us,sc.p99_us' --limit 5 --format simple"),
172
173 ("io_latency", "I/O latency percentiles",
174 f"{base_cmd} -g 'state,exe' -l 'io.min_lat_us,io.avg_lat_us,io.max_lat_us' --limit 5 --format simple"),
175
176 ("syscall_histogram", "System call histogram",

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68