Skip to content

Commit 8d6654a

Browse files
committed
Complete binding for trace type
1 parent e3ea98f commit 8d6654a

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
from __future__ import annotations
22

3-
import enum
4-
5-
6-
class TraceType(enum.Enum):
7-
CSV_TRACE = 0
8-
BIN_TRACE = 1
9-
PLAIN_TXT_TRACE = 2
10-
ORACLE_GENERAL_TRACE = 3
11-
LCS_TRACE = 4 # libCacheSim format
3+
# Import TraceType directly from the C++ binding to avoid duplication
4+
from ._libcachesim import TraceType

libCacheSim-python/src/pylibcachesim.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ struct ReaderDeleter {
161161
}
162162
};
163163

164-
namespace py = pybind11;
165-
166164
PYBIND11_MODULE(_libcachesim, m) { // NOLINT(readability-named-parameter)
167165
m.doc() = R"pbdoc(
168166
libCacheSim Python bindings
@@ -178,9 +176,19 @@ PYBIND11_MODULE(_libcachesim, m) { // NOLINT(readability-named-parameter)
178176

179177
py::enum_<trace_type_e>(m, "TraceType")
180178
.value("CSV_TRACE", trace_type_e::CSV_TRACE)
181-
.value("PLAIN_TXT_TRACE", trace_type_e::PLAIN_TXT_TRACE)
182179
.value("BIN_TRACE", trace_type_e::BIN_TRACE)
180+
.value("PLAIN_TXT_TRACE", trace_type_e::PLAIN_TXT_TRACE)
181+
.value("ORACLE_GENERAL_TRACE", trace_type_e::ORACLE_GENERAL_TRACE)
182+
.value("LCS_TRACE", trace_type_e::LCS_TRACE)
183183
.value("VSCSI_TRACE", trace_type_e::VSCSI_TRACE)
184+
.value("TWR_TRACE", trace_type_e::TWR_TRACE)
185+
.value("TWRNS_TRACE", trace_type_e::TWRNS_TRACE)
186+
.value("ORACLE_SIM_TWR_TRACE", trace_type_e::ORACLE_SIM_TWR_TRACE)
187+
.value("ORACLE_SYS_TWR_TRACE", trace_type_e::ORACLE_SYS_TWR_TRACE)
188+
.value("ORACLE_SIM_TWRNS_TRACE", trace_type_e::ORACLE_SIM_TWRNS_TRACE)
189+
.value("ORACLE_SYS_TWRNS_TRACE", trace_type_e::ORACLE_SYS_TWRNS_TRACE)
190+
.value("VALPIN_TRACE", trace_type_e::VALPIN_TRACE)
191+
.value("UNKNOWN_TRACE", trace_type_e::UNKNOWN_TRACE)
184192
.export_values();
185193

186194
// *************** structs ***************

libCacheSim-python/tests/test_process_trace.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import sys
77
import os
8+
import pytest
89

910
# Add the parent directory to the Python path for development testing
1011
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
@@ -28,7 +29,7 @@ def create_trace_reader():
2829
)
2930
if not os.path.exists(data_file):
3031
return None
31-
return lcs.open_trace(data_file, lcs.TraceType.ORACLE_GENERAL_TRACE.value)
32+
return lcs.open_trace(data_file, lcs.TraceType.ORACLE_GENERAL_TRACE)
3233

3334

3435
def test_process_trace_native():
@@ -38,8 +39,7 @@ def test_process_trace_native():
3839
# Open trace
3940
reader = create_trace_reader()
4041
if reader is None:
41-
print("Warning: Test trace file not found, skipping test")
42-
return # Skip test
42+
pytest.skip("Test trace file not found, skipping test")
4343

4444
# Create LRU cache
4545
cache = lcs.LRU(1024*1024) # 1MB cache
@@ -61,8 +61,7 @@ def test_process_trace_python_hook():
6161
# Open trace
6262
reader = create_trace_reader()
6363
if reader is None:
64-
print("Warning: Test trace file not found, skipping test")
65-
return # Skip test
64+
pytest.skip("Test trace file not found, skipping test")
6665

6766
# Create Python hook LRU cache
6867
cache = lcs.PythonHookCachePolicy(1024*1024, "TestLRU")
@@ -126,8 +125,7 @@ def test_compare_native_vs_python_hook():
126125
native_cache = lcs.LRU(cache_size)
127126
reader1 = create_trace_reader()
128127
if reader1 is None:
129-
print("Warning: Test trace file not found, skipping test")
130-
return # Skip test
128+
pytest.skip("Test trace file not found, skipping test")
131129

132130
native_miss_ratio = native_cache.process_trace(reader1, max_req=max_requests)
133131

@@ -175,8 +173,7 @@ def test_error_handling():
175173

176174
reader = create_trace_reader()
177175
if reader is None:
178-
print("Warning: Test trace file not found, skipping error test")
179-
return # Skip test
176+
pytest.skip("Test trace file not found, skipping error test")
180177

181178
# Try to process trace without setting hooks
182179
try:
@@ -199,8 +196,7 @@ def test_lru_implementation_accuracy():
199196
reader2 = create_trace_reader()
200197

201198
if not reader1 or not reader2:
202-
print("Warning: Cannot open trace files for LRU accuracy test")
203-
return
199+
pytest.skip("Cannot open trace files for LRU accuracy test")
204200

205201
# Test native LRU
206202
native_cache = lcs.LRU(cache_size)

libCacheSim-python/tests/test_unified_interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def create_trace_reader():
2929
)
3030
if not os.path.exists(data_file):
3131
return None
32-
return lcs.open_trace(data_file, lcs.TraceType.ORACLE_GENERAL_TRACE.value)
32+
return lcs.open_trace(data_file, lcs.TraceType.ORACLE_GENERAL_TRACE)
3333

3434

3535
def create_test_lru_hooks():

0 commit comments

Comments
 (0)