Skip to content

Commit

Permalink
added test case for JPEG
Browse files Browse the repository at this point in the history
  • Loading branch information
hariharan-devarajan committed Aug 22, 2023
1 parent 2aafad4 commit d925697
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set_property(TEST test APPEND PROPERTY ENVIRONMENT DLIO_PROFILER_LOG_LEVEL=INFO)

find_program(PYTHON_EXE python)
message("-- Found python at location " ${PYTHON_EXE})
add_test(test_py python3 ${CMAKE_CURRENT_SOURCE_DIR}/test.py)
add_test(test_py ${PYTHON_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/test.py)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/test/data)
set_property(TEST test_py APPEND PROPERTY ENVIRONMENT PYTHONPATH=$ENV{PYTHONPATH}:${CMAKE_SOURCE_DIR}/venv/lib)
set_property(TEST test_py APPEND PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:${CMAKE_SOURCE_DIR}/dependency/.spack-env/view/lib64)
Expand Down
14 changes: 12 additions & 2 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def posix_calls1(index):
f.close()

import numpy as np

import PIL.Image as im
def posix_calls2(index):
#print(f"{cwd}/data/demofile2.npz")
path = f"{cwd}/data/demofile{index}.npz"
Expand All @@ -33,13 +33,23 @@ def posix_calls2(index):
record_labels = [0] * 1024
np.savez(path, x=records, y=record_labels)

def write_read_jpeg(index):
records = np.random.randint(255, size=(1024, 1024), dtype=np.uint8)
img = im.fromarray(records)
out_path_spec = f"{cwd}/data/test.jpeg"
img.save(out_path_spec, format='JPEG', bits=8)
with open(out_path_spec, "rb") as f:
image = im.open(f)
#image = im.open(out_path_spec)
out_records = np.asarray(image)

import threading

logger.initialize(f"{cwd}/log.pwf", f"{cwd}/data")
t1 = threading.Thread(target=posix_calls1, args=(10,))
custom_events()
t2 = threading.Thread(target=posix_calls2, args=(1,))
t3 = threading.Thread(target=posix_calls2, args=(2,))
t3 = threading.Thread(target=write_read_jpeg, args=(2,))
# starting thread 1
t1.start()
t2.start()
Expand Down

0 comments on commit d925697

Please sign in to comment.