Skip to content

Commit c1c6112

Browse files
committed
Add 25 seconds wait time (at most) for clamd.ctl + Update EICAR signature name
1 parent 3b09674 commit c1c6112

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

.github/workflows/tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,15 @@ jobs:
4242
sudo freshclam --verbose
4343
sudo systemctl restart clamav-daemon.service
4444
45+
- name: Wait for 25 seconds until clamd socket becomes available
46+
run: |
47+
secs=25
48+
while [[ $secs -gt 0 ]] && ! [[ -f "/var/run/clamav/clamd.ctl" ]];
49+
do
50+
echo -ne "$secs\033[0K\r"
51+
sleep 1
52+
: $((secs--))
53+
done
54+
4555
- name: Run unit tests
4656
run: pytest

src/tests/test_api.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
mine = (stat.S_IREAD | stat.S_IWRITE)
1212
other = stat.S_IROTH
1313
execute = (stat.S_IEXEC | stat.S_IXOTH)
14+
EICAR_SIG_NAME = "Win.Test.EICAR_HDB-1"
1415

1516

1617
@contextmanager
@@ -42,7 +43,7 @@ def test_scan(self):
4243
f.write(clamd.EICAR)
4344
f.flush()
4445
os.fchmod(f.fileno(), (mine | other))
45-
expected = {f.name: ('FOUND', 'Eicar-Test-Signature')}
46+
expected = {f.name: ('FOUND', EICAR_SIG_NAME)}
4647

4748
assert self.cd.scan(f.name) == expected
4849

@@ -51,7 +52,7 @@ def test_unicode_scan(self):
5152
f.write(clamd.EICAR)
5253
f.flush()
5354
os.fchmod(f.fileno(), (mine | other))
54-
expected = {f.name: ('FOUND', 'Eicar-Test-Signature')}
55+
expected = {f.name: ('FOUND', EICAR_SIG_NAME)}
5556

5657
assert self.cd.scan(f.name) == expected
5758

@@ -62,13 +63,13 @@ def test_multiscan(self):
6263
with open(os.path.join(d, "file" + str(i)), 'wb') as f:
6364
f.write(clamd.EICAR)
6465
os.fchmod(f.fileno(), (mine | other))
65-
expected[f.name] = ('FOUND', 'Eicar-Test-Signature')
66+
expected[f.name] = ('FOUND', EICAR_SIG_NAME)
6667
os.chmod(d, (mine | other | execute))
6768

6869
assert self.cd.multiscan(d) == expected
6970

7071
def test_instream(self):
71-
expected = {'stream': ('FOUND', 'Eicar-Test-Signature')}
72+
expected = {'stream': ('FOUND', EICAR_SIG_NAME)}
7273
assert self.cd.instream(BytesIO(clamd.EICAR)) == expected
7374

7475
def test_insteam_success(self):
@@ -79,7 +80,7 @@ def test_fdscan(self):
7980
f.write(clamd.EICAR)
8081
f.flush()
8182
os.fchmod(f.fileno(), (mine | other))
82-
expected = {f.name: ('FOUND', 'Eicar-Test-Signature')}
83+
expected = {f.name: ('FOUND', EICAR_SIG_NAME)}
8384

8485
assert self.cd.fdscan(f.name) == expected
8586

0 commit comments

Comments
 (0)