From 97ac439ef7b759223b018f7534d88827a70db356 Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Fri, 23 Oct 2009 18:28:39 +0300 Subject: [PATCH] updated integer constraints in p2p-log-sqlite.sql; added negative test cases in access_db --- auto/bd/access_db | 19 ++++++++++++------- auto/sql/p2p-log-sqlite.sql | 34 +++++++++++++++++----------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/auto/bd/access_db b/auto/bd/access_db index 14bc000..cdf22d1 100755 --- a/auto/bd/access_db +++ b/auto/bd/access_db @@ -26,7 +26,7 @@ class DatabaseAccess: return self.conn def get_status(self): - tables = ['swarms', 'btclients', 'swarms', 'client_session', 'status_messages', 'verbose_messages'] + tables = ['swarms', 'btclients', 'client_session', 'status_messages', 'verbose_messages'] for t in tables: try: self.cursor.execute("select * from '%s'" %t) @@ -97,24 +97,29 @@ def main(): for t in [('DarkKnight', '123000', 'experiment', 'TVTorrents'), ('Fedora', '1024', 'experiment', 'local'), ('Pulp Fiction', '102400', 'streaming', 'isohunt'), + ('Karaoke', 'anaaremere', 'streaming', 'local'), ]: dba.insert_swarms_row(t) - for t in [('Tribler', 'Python', 1, 1), - ('libtorrent', 'C++', 1, 0), - ('Vuze', 'Java', 1, 0), + for t in [('Tribler', 'Python', '1', '1'), + ('libtorrent', 'C++', '1', '0'), + ('Vuze', 'Java', '1', '0'), + ('Transmission', 'C', 'asa', '0'), ]: dba.insert_btclients_row(t) - for t in [('1', '2', 'Linux', '2.6.30', '256', '1833', '0.0.0.0', '6969', '256', '96', '123131.1231') + for t in [('1', '2', 'Linux', '2.6.30', '256', '1833', '0.0.0.0', '6969', '256', '96', '123131.1231'), + ('3', '4', 'Linux', '2.6.30', '256', '1833', '0.0.0.0', '6969', '256', '96', '123131.1231'), ]: dba.insert_client_session_row(t) - for t in [('1', '2455128.10', '222', '0', '213', '56', '200', '300', '121.324') + for t in [('1', '2455128.10', '222', '0', '213', '56', '200', '300', '121.324'), + ('6', '2455128.10', '222', '0', '213', '56', '200', '300', '121.324'), ]: dba.insert_status_messages_row(t) - for t in [('1', '2455128.121295811', '127.0.0.1', '1345', '0', '3', '4', '13', '777') + for t in [('1', '2455128.121295811', '127.0.0.1', '1345', '0', '3', '4', '13', '777'), + ('4', '2455128.121295811', '127.0.0.1', '1345', '0', '3', '4', '13', '777'), ]: dba.insert_verbose_messages_row(t) diff --git a/auto/sql/p2p-log-sqlite.sql b/auto/sql/p2p-log-sqlite.sql index 81af91c..81c8a2b 100644 --- a/auto/sql/p2p-log-sqlite.sql +++ b/auto/sql/p2p-log-sqlite.sql @@ -7,7 +7,7 @@ drop table if exists swarms; create table swarms( id integer primary key autoincrement, torrent text, - filesize integer, + filesize integer check(filesize between 0 and 100000000000), purpose text, source text); @@ -24,23 +24,23 @@ create table client_session( client_id integer references btclients(id), system_os text, system_os_version text, - system_ram integer, - system_cpu integer, + system_ram integer check (system_ram between 0 and 32768), + system_cpu integer check (system_cpu between 100 and 10000), public_ip text, - public_port integer, - ds_limit integer, - us_limit integer, + public_port integer check (public_port between 1 and 65535), + ds_limit integer check (ds_limit between 0 and 1000000), + us_limit integer check (us_limit between 0 and 1000000), start_time date); create table status_messages ( cs_id integer references client_session(id), timestamp date, - peer_num integer, - dht integer, - download_speed integer, - upload_speed integer, - download_size integer, - upload_size integer, + peer_num integer check (peer_num between 0 and 100000), + dht integer check (dht between 0 and 100000), + download_speed integer check (download_speed between 0 and 1000000), + upload_speed integer check (upload_speed between 0 and 1000000), + download_size integer check(download_size between 0 and 100000000000), + upload_size integer check(upload_size between 0 and 100000000000), eta date); create table verbose_messages ( @@ -48,10 +48,10 @@ create table verbose_messages ( timestamp date, peer_ip text, peer_port integer check(peer_port between 1 and 65535), - message_type integer, - _index integer, - begin integer, - length integer, + message_type integer check (message_type between 0 and 100), + _index integer check (_index between 0 and 100000), + begin integer check (begin between 0 and 10000000), + length integer check (length between 0 and 10000000), listen_port integer check(listen_port between 1 and 65535)); -.genfkey --exec \ No newline at end of file +.genfkey --exec -- 2.20.1