Skip to content

Commit c456c25

Browse files
authored
add sqlite support (#10)
1 parent ebf45f0 commit c456c25

8 files changed

Lines changed: 29 additions & 11 deletions

File tree

build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ def build_db_image(cfg, use_cache, custom=False, dockerfile_path=""):
5555
def build_environment(cfg, use_cache, custom=False, dockerfile_path=""):
5656
build_network()
5757
build_sqlancer_image(force_rebuild=not use_cache)
58-
build_db_image(cfg, use_cache, custom, dockerfile_path)
58+
if cfg["embedded"] == "no":
59+
build_db_image(cfg, use_cache, custom, dockerfile_path)
5960

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"dbms_list": ["mysql", "postgres"],
2+
"dbms_list": ["mysql", "postgres", "sqlite"],
33
"dbms": "mysql",
44
"container_name": "mysql-custom",
55
"image": "mysql-custom",

mysql/config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"embedded": "no",
3+
"dbms": "mysql",
24
"image": "mysql:8.0",
35
"container_name": "mysql-sqlancer",
46
"port": 3306,

postgres/config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"embedded": "no",
3+
"dbms": "postgres",
24
"image": "postgres:13",
35
"container_name": "postgres-sqlancer",
46
"port": 5432,
@@ -8,7 +10,7 @@
810
},
911
"username": "postgres",
1012
"password": "12345678",
11-
"oracle": "NOREC",
13+
"oracle": "NoREC",
1214
"num_threads": 4,
1315
"timeout_seconds": 60,
1416
"init_sql": "CREATE DATABASE test;",

sqlite/__init__.py

Whitespace-only changes.

sqlite/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"embedded": "yes",
3+
"dbms": "sqlite3",
4+
"username": "localhost",
5+
"password": "localhost",
6+
"container_name": "localhost",
7+
"oracle": "NoREC",
8+
"num_threads": 4,
9+
"timeout_seconds": 60
10+
}
11+

start.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ def main():
4747
print(f"[WARNING] Skipping {dbms}, missing config file.")
4848
continue
4949
cfg = load_json(config_path)
50-
build_environment(args.dbms, cfg, use_cache)
51-
test_single(dbms, cfg, use_cache)
50+
build_environment(cfg, use_cache)
51+
test_single(cfg, use_cache)
5252

5353
elif args.dbms:
5454
if not args.config:
5555
parser.error("Single DBMS test requires --config")
5656
cfg = load_json(args.config)
57-
build_environment(args.dbms, cfg, use_cache)
58-
test_single(args.dbms, cfg, use_cache)
57+
build_environment(cfg, use_cache)
58+
test_single(cfg, use_cache)
5959

6060
else:
6161
parser.error("Must specify either --dbms or --dockerfile")

test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ def start_sqlancer_container(dbms, host_container_name, username, password, orac
8787
])
8888

8989

90-
def test_single(dbms, cfg, use_cache=False):
90+
def test_single(cfg, use_cache=False):
91+
if cfg["embedded"] == "no":
92+
start_db_container(cfg["dbms"], cfg)
9193

92-
start_db_container(dbms, cfg)
9394
start_sqlancer_container(
94-
dbms=dbms,
95+
dbms=cfg["dbms"],
9596
host_container_name=cfg["container_name"],
9697
username=cfg["username"],
9798
password=cfg["password"],
@@ -100,7 +101,8 @@ def test_single(dbms, cfg, use_cache=False):
100101
timeout=cfg["timeout_seconds"]
101102
)
102103

103-
remove_container(cfg["container_name"])
104+
if cfg["embedded"] == "no":
105+
remove_container(cfg["container_name"])
104106

105107
def remove_container(container_name):
106108
try:

0 commit comments

Comments
 (0)