source:
ogServer-Git/tests/run-tests.py
@
496f5eb
Last change on this file since 496f5eb was 727a109, checked in by , 5 years ago | |
---|---|
|
|
File size: 2.0 KB |
Rev | Line | |
---|---|---|
[727a109] | 1 | #!/usr/bin/env python3 |
2 | ||
3 | import subprocess, glob, os | |
4 | ||
5 | 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');" | |
6 | ||
7 | sql_create_user = "CREATE USER 'test-db'@'hostname'; GRANT ALL PRIVILEGES ON *.* To 'test-db'@'hostname' IDENTIFIED BY 'test-db';" | |
8 | ||
9 | sql_delete_user = "DROP USER 'test-db'@'hostname';" | |
10 | ||
11 | def start_mysql(): | |
12 | ||
13 | subprocess.run(['mysqladmin', 'drop', '-f', 'test-db'], | |
14 | stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) | |
15 | subprocess.run(['mysqladmin', 'create', 'test-db']) | |
16 | subprocess.run('mysql --default-character-set=utf8 test-db < ../../../../Database/ogAdmBD.sql', shell=True) | |
17 | subprocess.run(['mysql', '-D', 'test-db', '-e', sql_data]) | |
18 | subprocess.run(['mysql', '-D', 'test-db', '-e', sql_create_user]) | |
19 | ||
20 | return | |
21 | ||
22 | def stop_mysql(): | |
23 | ||
24 | subprocess.run(['mysql', '-D', 'test-db', '-e', sql_delete_user]) | |
25 | subprocess.run(['mysqladmin', 'drop', '-f', 'test-db']) | |
26 | ||
27 | return | |
28 | ||
29 | if os.getuid() is not 0: | |
30 | print('You need to be root to run these tests :-)') | |
31 | exit() | |
32 | ||
33 | start_mysql(); | |
34 | ||
35 | subprocess.Popen(['../ogAdmServer', '-f', 'config/ogAdmServer.cfg']) | |
36 | ||
37 | for filename in glob.iglob('units/**'): | |
38 | subprocess.run(['python3', filename, '-v']) | |
39 | ||
40 | stop_mysql(); | |
41 | ||
42 | subprocess.run(['pkill', 'ogAdmServer']) |
Note: See TracBrowser
for help on using the repository browser.