Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
stratospher committed Feb 12, 2022
1 parent 7712f33 commit d948929
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ task:
env:
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
FILE_ENV: "./ci/test/00_setup_env_native_fuzz.sh"
python_script:
- python src/test/fuzz/script.py
# python_script:
## - if [ "$CIRRUS_PR" = "" ]; then python src/test/fuzz/script.py; fi
# - python src/test/fuzz/script.py

#task:
# name: '[multiprocess, i686, DEBUG] [focal]'
Expand Down
6 changes: 5 additions & 1 deletion src/test/fuzz/crypto_diff_fuzz_pychacha20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ void send_to_python(int sockfd, uint32_t num)
FUZZ_TARGET(crypto_diff_fuzz_pychacha20)
{
/* ----------------------- socket initialisation -------------------------- */
std::cout << "socket initialisation\n";
struct sockaddr_un addr;

// Create a new client socket with domain: AF_UNIX, type: SOCK_STREAM, protocol: 0
Expand Down Expand Up @@ -167,7 +168,9 @@ FUZZ_TARGET(crypto_diff_fuzz_pychacha20)
exit(1);
}
/* ----------------------- initialisation over ----------------------- */
std::cout << "socket initialisation over\n";
/* ----------------------- fuzzing phase ------------------------------ */
std::cout << "fuzzing initialisation\n";
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
ChaCha20 chacha20;

Expand All @@ -180,7 +183,7 @@ FUZZ_TARGET(crypto_diff_fuzz_pychacha20)
std::vector<unsigned char> response = read_from_python(sockfd);
std::string s1(response.begin(), response.end());
assert(s1 == "ok");

std::cout<<"py response obtained\n";
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 3000)
{
CallOneOf(
Expand Down Expand Up @@ -214,5 +217,6 @@ FUZZ_TARGET(crypto_diff_fuzz_pychacha20)
std::string s2(response.begin(), response.end());
assert(s2 == "ok");
/* ----------------------- end fuzzing phase ----------------------- */
std::cout << "fuzzing over\n";
close(sockfd);
}
5 changes: 3 additions & 2 deletions src/test/fuzz/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
os.remove("/tmp/socket_test.s")

def main():
print("Script Hello!!!")
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.settimeout(60)
s.bind("/tmp/socket_test.s")
s.listen(1)
while True:
Expand Down Expand Up @@ -71,4 +71,5 @@ def main():
raise Exception("Unrecognised cmd")

if __name__ == "__main__":
main()
main()
print("Script Bye!!!")
13 changes: 12 additions & 1 deletion test/fuzz/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ def main():
logging.info("Please consider adding a fuzz corpus at https://github.com/bitcoin-core/qa-assets")

try:
if 'crypto_diff_fuzz_pychacha20' in args.target:
# # output += "hi"
subprocess.Popen('src/test/fuzz/script.py', shell = True)
# # sleep(10)
# # output += "bye"
help_output = subprocess.run(
args=[
os.path.join(config["environment"]["BUILDDIR"], 'src', 'test', 'fuzz', 'fuzz'),
Expand Down Expand Up @@ -217,7 +222,7 @@ def job(command, t):
for future in as_completed(futures):
future.result()


# todo: what's this?
def merge_inputs(*, fuzz_pool, corpus, test_list, src_dir, build_dir, merge_dir):
logging.info("Merge the inputs from the passed dir into the corpus_dir. Passed dir {}".format(merge_dir))
jobs = []
Expand Down Expand Up @@ -266,6 +271,12 @@ def run_once(*, fuzz_pool, corpus, test_list, src_dir, build_dir, use_valgrind):

def job(t, args):
output = 'Run {} with args {}'.format(t, args)
# import ipdb; ipdb.set_trace()
# if t == 'crypto_diff_fuzz_pychacha20':
# output += "hi"
# subprocess.Popen(['python','src/test/fuzz/script.py'])
# sleep(10)
# output += "bye"
result = subprocess.run(
args,
env=get_fuzz_env(target=t, source_dir=src_dir),
Expand Down

0 comments on commit d948929

Please sign in to comment.