Skip to content

Commit

Permalink
Adding unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusaa committed Feb 26, 2024
1 parent c4eb863 commit fdd300d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
45 changes: 45 additions & 0 deletions unit_tests/clamscan/alz_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (C) 2020-2024 Cisco Systems, Inc. and/or its affiliates. All rights reserved.

"""
Run clamscan tests.
"""

import sys

sys.path.append('../unit_tests')
import testcase


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_pdf_hook(self):
self.step_name('Test alz files compressed with deflate (gzip)')

testfile = TC.path_source / 'unit_tests' / 'input' / 'other_scanfiles' / 'deflate.alz'
command = '{valgrind} {valgrind_args} {clamscan} -d {path_db} {testfile}'.format(
valgrind=TC.valgrind, valgrind_args=TC.valgrind_args, clamscan=TC.clamscan,
path_db=TC.path_source / 'unit_tests' / 'input' / 'other_sigs' / 'alz.hdb',
testfile=testfile,
)
output = self.execute_command(command)

assert output.ec == 1 # virus

expected_results = [
'test.txt.UNOFFICIAL FOUND',
]
self.verify_output(output.out, expected=expected_results)
Binary file added unit_tests/input/other_scanfiles/deflate.alz
Binary file not shown.
5 changes: 5 additions & 0 deletions unit_tests/input/other_sigs/alz.hdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
9645df16bc733a92129563ad2e5f1f6a9ed483c9:16:test.txt
12f41f69d25d0ba9b73da429e0d69b27c95522db:16:test.txt
03d4c70e6aa3832fa51959137b6a3fc55d8b9f55:16:test.txt
26c0e077ad49260d416dbf449569efbc7ce02448:16:test.txt
67b33eebc1e4537d839bc6b04affd6b06074c746:13:test.txt

0 comments on commit fdd300d

Please sign in to comment.