Files
clamav/unit_tests/libclamav_test.py
Micah Snyder 201e1b12a7 XOR test files; clean up tests directory
The split test files are flagged by some AV's because they look like
broken executables. Instead of splitting the test files to prevent
detections, we should encrypt them. This commit replaces the "reassemble
testfiles" script with a basic "XOR testfiles" script that can be used
to encrypt or decrypt test files. This commit also of course then
replaces all the split files with xor'ed files.

The test and unit_tests directories were a bit of a mess, so I
reorganized them all into unit_tests with all of the test files placed
under "unit_tests/input" using subdirectories for different types of files.
2021-07-17 10:39:27 -07:00

53 lines
1.2 KiB
Python

# Copyright (C) 2020-2021 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
"""
Run libclamav unit tests
"""
import os
from pathlib import Path
import platform
import subprocess
import sys
import time
import unittest
import testcase
os_platform = platform.platform()
operating_system = os_platform.split('-')[0].lower()
class TC(testcase.TestCase):
@classmethod
def setUpClass(cls):
super(TC, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TC, cls).tearDownClass()
def setUp(self):
super(TC, self).setUp()
def tearDown(self):
super(TC, self).tearDown()
self.verify_valgrind_log()
def test_libclamav_00_unit_test(self):
self.step_name('libclamav unit tests')
# If no valgrind, valgrind nad valgrind args are empty strings
command = '{valgrind} {valgrind_args} {check_clamav}'.format(
valgrind=TC.valgrind, valgrind_args=TC.valgrind_args, check_clamav=TC.check_clamav
)
output = self.execute_command(command)
assert output.ec == 0 # success
expected_results = [
'100%', 'Failures: 0', 'Errors: 0'
]
self.verify_output(output.out, expected=expected_results)