from TotOnline import TotOnline from StartUpTest import StartUPTest class Main: def __init__(self): print("Main class instantiated") def process_data_in_chunks(data, chunk_size=1000000): chunks = [data[i:i+chunk_size] for i in range(0, len(data), chunk_size)] return chunks if __name__ == "__main__": filename = "resources/SmallTest.txt" with open(filename, "rb") as f: binary_data = f.read().strip() with open(filename, "rb") as f: byte_data = f.read().strip() print("Run all StartUPTests") binary_chunks = process_data_in_chunks(byte_data) first_chunk = binary_chunks[0] result = StartUPTest.run_all_tests(first_chunk) print(result) print("Run all TotOnline tests") binary_chunks = process_data_in_chunks(byte_data) first_chunk = binary_chunks[0] result = TotOnline.run_all_tests(first_chunk) print(result) # Call the StartUpTest print("StartUp:") binary_chunks = process_data_in_chunks(byte_data) first_chunk = binary_chunks[0] result = StartUPTest.monobit_test(first_chunk) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) result = StartUPTest.chi_square(first_chunk) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) print("Chi2_statistic", result[2]) # Call the TotalFailure-Test print("Total Failure:") byte_chunks = process_data_in_chunks(byte_data) first_chunk = byte_chunks[0] result = TotOnline.total_failure_test(first_chunk, pattern_length=10) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) # Call the Online Test print("Monobit:") byte_chunks = process_data_in_chunks(byte_data) first_chunk = byte_chunks[0] result = TotOnline.monobit_test(first_chunk) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) print("Block Frequency:") byte_chunks = process_data_in_chunks(byte_data) first_chunk = byte_chunks[0] result = TotOnline.block_frequency_test(first_chunk) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) print("Run:") byte_chunks = process_data_in_chunks(byte_data) first_chunk = byte_chunks[0] result = TotOnline.run_test(first_chunk) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) print("Longest Run:") byte_chunks = process_data_in_chunks(byte_data) first_chunk = byte_chunks[0] result = TotOnline.longest_one_block_test(first_chunk) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1])