Skip to content

Commit

Permalink
allow fuzzcorp section tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kbhargava-jump committed Sep 5, 2024
1 parent 67b5aec commit fdd4d12
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ $ solana-test-suite debug-mismatches [OPTIONS]
* `-t, --target PATH`: Shared object (.so) target file paths (pairs with --keep-passing). Targets must have sol_compat_instr_execute_v1 defined [default: /home/kbhargava/repos/firedancer/build/native/gcc/lib/libfd_exec_sol_compat.so]
* `-o, --output-dir PATH`: Output directory for InstrContext messages [default: debug_mismatch]
* `-u, --repro-urls TEXT`: Comma-delimited list of FuzzCorp mismatch links
* `-s, --section-names TEXT`: Comma-delimited list of FuzzCorp section names
* `-f, --fuzzcorp-url TEXT`: Comma-delimited list of FuzzCorp section names
* `--help`: Show this message and exit.

## `solana-test-suite decode-protobuf`
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies = [
"Cython>=3.0.9",
"tqdm~=4.66.0",
"protoletariat~=3.2.0",
"bs4~=4.12.3",
]

[project.scripts]
Expand Down
45 changes: 45 additions & 0 deletions src/test_suite/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import tqdm
from test_suite.fuzz_context import *
import os
from urllib.parse import urljoin
from bs4 import BeautifulSoup

"""
Harness options:
Expand Down Expand Up @@ -544,9 +546,52 @@ def debug_mismatches(
repro_urls: str = typer.Option(
"", "--repro-urls", "-u", help="Comma-delimited list of FuzzCorp mismatch links"
),
section_names: str = typer.Option(
"",
"--section-names",
"-s",
help="Comma-delimited list of FuzzCorp section names",
),
fuzzcorp_url: str = typer.Option(
"",
"--fuzzcorp-url",
"-f",
help="Comma-delimited list of FuzzCorp section names",
),
):
fuzzcorp_cookie = os.getenv("FUZZCORP_COOKIE")
repro_urls_list = repro_urls.split(",") if repro_urls else []
section_names_list = section_names.split(",") if section_names else []

url = "https://api.dev.fuzzcorp.asymmetric.re/uglyweb/firedancer-io/solfuzz/bugs/"
curl_command = f"curl {fuzzcorp_url} --cookie s={fuzzcorp_cookie}"
result = subprocess.run(curl_command, shell=True, capture_output=True, text=True)
page_content = result.stdout
soup = BeautifulSoup(page_content, "html.parser")
for section_name in section_names_list:
section_anchor = soup.find("a", {"name": f"lin_{section_name}"})

if section_anchor:
next_element = section_anchor.find_next_sibling()
while next_element:
if next_element.name == "table":
hrefs = [a["href"] for a in next_element.find_all("a", href=True)]
for href in hrefs:
repro_urls_list.append(urljoin(url, href))
break
elif next_element.name == "p" and "No bugs found" in next_element.text:
print(f"No bugs found for section {section_name}.")
break
elif next_element.name == "a" and next_element.has_attr("name"):
print(f"No table found in section {section_name}.")
break

next_element = next_element.find_next_sibling()

if not next_element:
print(f"No relevant content found after section {section_name}.")
else:
print(f"Section {section_name} not found.")

custom_data_urls = []
for url in repro_urls_list:
Expand Down

0 comments on commit fdd4d12

Please sign in to comment.