#915 Add Valgrind to python tests

ogServer has some memory bugs we want to solve and avoid in the future.
Run ogServer with Valgrind to help us find those errors.
master
Javier Sánchez Parra 2021-02-23 08:35:34 +01:00 committed by OpenGnSys Support Team
parent a46b69b590
commit f798e03e18
1 changed files with 10 additions and 3 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
import subprocess, glob, os
import subprocess, glob, time, os
sql_data = "INSERT INTO aulas (nombreaula, idcentro, urlfoto, grupoid, ubicacion, puestos, modomul, ipmul, pormul, velmul, router, netmask, ntp, dns, proxy, modp2p, timep2p) VALUES ('Aula virtual', 1, 'aula.jpg', 0, 'Despliegue virtual con Vagrant.', 5, 2, '239.194.2.11', 9000, 70, '192.168.56.1', '255.255.255.0', '', '', '', 'peer', 30); INSERT INTO ordenadores (nombreordenador, ip, mac, idaula, idrepositorio, idperfilhard, idmenu, idproautoexec, grupoid, router, mascara, arranque, netiface, netdriver, fotoord) VALUES ('pc2', '192.168.2.1', '0800270E6501', 1, 1, 0, 0, 0, 0, '192.168.56.1', '255.255.255.0', '00unknown', 'eth0', 'generic', 'fotoordenador.gif'), ('pc2', '192.168.2.2', '0800270E6502', 1, 1, 0, 0, 0, 0, '192.168.56.1', '255.255.255.0', '00unknown', 'eth0', 'generic', 'fotoordenador.gif');"
@ -30,12 +30,19 @@ if os.path.isfile('../ogserver') is not True:
print('You need to build the ogserver binary to run these tests :-)')
exit()
if os.path.isfile('/usr/bin/valgrind') is not True:
print('You need valgrind to run these tests :-)')
exit()
start_mysql();
subprocess.Popen(['../ogserver -f config/ogserver.json'], shell=True)
subprocess.Popen(['valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=./valgrind-out.log ../ogserver -f config/ogserver.json'], shell=True)
print("Waiting 5 seconds for daemon to be read...")
time.sleep(5)
subprocess.run('python3 -m unittest discover -s units -v', shell=True)
stop_mysql();
subprocess.run(['pkill', 'ogserver'])
subprocess.run(['pkill', '-f', 'valgrind'])