-
Notifications
You must be signed in to change notification settings - Fork 1
/
soc_test.py
124 lines (107 loc) · 4.66 KB
/
soc_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from cmath import nan
import subprocess,os,json
from unittest import TestCase
# class SoC_Tester(TestCase):
# def test_soc_combination(self):
# # assert True
# # os.chdir("../../")
# print(f"CURRENT DIR = {os.system('pwd')}")
# defaults = {"i": 1, "gpio": 1}
# extensions = {"m": 1, "f": 0, "c": 0}
# devices = {"spi": 0, "uart": 0, "timer": 0, "spi_flash": 1, "i2c": 0}
# bus = {"wb": 0, "tl": 0}
# total_combinations = 2**len(extensions.keys()) * 2**len(devices.keys()) * len(bus.keys())
# print(f"\n Total Combinations: {total_combinations}\n")
# comb_count = 0
# import itertools
# from typing import final
# device_combs = list(itertools.product([0, 1], repeat=len(devices.keys())))
# extension_combs = list(itertools.product([0, 1], repeat=len(extensions.keys())))
# bus_combs = [ [0]*len(bus.keys()) for i,v in enumerate(bus.keys())]
# for i,v in enumerate(bus_combs):
# v[i] = 1
# for i,v in enumerate(bus_combs):
# # current bus comb
# final_dict = dict(zip(bus.keys(), v))
# for j,w in enumerate(extension_combs):
# # current ext comb
# final_dict |= dict(zip(extensions.keys(), w))
# for k,x in enumerate(device_combs):
# # current dev comb
# final_dict |= dict(zip(devices.keys(), x))
# final_dict |= defaults
# # attach code here
# comb_count+=1
# print(f"\nCurrent Combination #{comb_count} : {final_dict}\n")
# file = open("src/main/scala/config.json","w")
# json.dump(final_dict, file)
# file.close()
# yield True
# process = subprocess.Popen(["sbt","test"], stdout=subprocess.PIPE)
# while True:
# output = process.stdout.readline()
# if output == '' and process.poll() is not None:
# break
# if output:
# # print(str(output))
# if "[info] All tests passed." in str(output):
# print("TEST PASSED :)")
# self.assertTrue(True)
# break
# if "TEST FAILED" in str(output):
# print("TEST FAILES :(")
# self.assertTrue(False)
# break
# break
# break
# break
def nana():
file = open("combinations.json","w")
json.dump({},file)
file.close()
print(f"CURRENT DIR = {os.system('pwd')}")
defaults = {"i": 1, "gpio": 1}
extensions = {"m": 1, "f": 0, "c": 0}
devices = {"spi": 0, "uart": 0, "timer": 0, "spi_flash": 1, "i2c": 0}
bus = {"wb": 0, "tl": 0}
total_combinations = 2**len(extensions.keys()) * 2**len(devices.keys()) * len(bus.keys())
print(f"\n Total Combinations: {total_combinations}\n")
comb_count = 0
import itertools
from typing import final
device_combs = list(itertools.product([0, 1], repeat=len(devices.keys())))
extension_combs = list(itertools.product([0, 1], repeat=len(extensions.keys())))
bus_combs = [ [0]*len(bus.keys()) for i,v in enumerate(bus.keys())]
for i,v in enumerate(bus_combs):
v[i] = 1
for i,v in enumerate(bus_combs):
# current bus comb
final_dict = dict(zip(bus.keys(), v))
for j,w in enumerate(extension_combs):
# current ext comb
final_dict |= dict(zip(extensions.keys(), w))
for k,x in enumerate(device_combs):
# current dev comb
final_dict |= dict(zip(devices.keys(), x))
final_dict |= defaults
# attach code here
print(f"\nCurrent Combination #{comb_count} : {final_dict}\n")
file = open("combinations.json")
data = json.load(file)
file.close()
file = open("combinations.json","w")
data[comb_count] = final_dict
json.dump(data, file)
file.close()
comb_count+=1
import sys
current_val = sys.argv[1]
if current_val == "all":
nana()
else:
file = open("combinations.json")
data = json.load(file)
file.close()
file = open("src/main/scala/config.json", "w")
json.dump(data[sys.argv[1]], file)
file.close()