diff --git a/.github/workflows/locked.yml b/.github/workflows/locked.yml index 751ade6880..358682a2f3 100644 --- a/.github/workflows/locked.yml +++ b/.github/workflows/locked.yml @@ -174,5 +174,4 @@ jobs: - name: Test Gobview run: | - ./goblint --enable gobview tests/regression/00-sanity/01-assert.c python3 scripts/test-gobview.py diff --git a/docs/user-guide/inspecting.md b/docs/user-guide/inspecting.md index 67aa86aa97..f4f6036f1b 100644 --- a/docs/user-guide/inspecting.md +++ b/docs/user-guide/inspecting.md @@ -22,4 +22,4 @@ To build GobView (also for development): 2. The executable for the http-server can then be found in the directory `./_build/default/gobview/goblint-http-server`. It takes the analyzer directory and additional Goblint configurations such as the files to be analyzed as parameters. Run it e.g. with the following command:\ `./_build/default/gobview/goblint-http-server/goblint_http.exe -with-goblint ../analyzer/goblint -goblint --set files[+] "../analyzer/tests/regression/00-sanity/01-assert.c"` -4. Visit +4. Visit diff --git a/scripts/test-gobview.py b/scripts/test-gobview.py index 0dc2cacaa4..1ac8f6a76c 100644 --- a/scripts/test-gobview.py +++ b/scripts/test-gobview.py @@ -7,32 +7,30 @@ from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options from threading import Thread -import http.server -import socketserver +import subprocess -PORT = 9000 +PORT = 8080 # has to match port defined in goblint_http.ml DIRECTORY = "run" IP = "localhost" url = 'http://' + IP + ':' + str(PORT) + '/' # cleanup -def cleanup(browser, httpd, thread): +def cleanup(browser, thread): print("cleanup") browser.close() - httpd.shutdown() - httpd.server_close() + p.kill() thread.join() # serve GobView in different thread so it does not block the testing -class Handler(http.server.SimpleHTTPRequestHandler): - def __init__(self, *args, **kwargs): - super().__init__(*args, directory=DIRECTORY, **kwargs) -class Server(socketserver.TCPServer): - allow_reuse_address = True # avoids that during a consecutive run the server cannot connect due to an 'Adress already in use' os error +def serve(): + global p + goblint_http_path = '_build/default/gobview/goblint-http-server/goblint_http.exe' + p = subprocess.Popen(['./' + goblint_http_path, + '-with-goblint', '../analyzer/goblint', + '-goblint', '--set', 'files[+]', '"../analyzer/tests/regression/00-sanity/01-assert.c"']) -httpd = Server((IP, PORT), Handler) print("serving at port", PORT) -thread = Thread(target=httpd.serve_forever, args=()) +thread = Thread(target=serve, args=()) thread.start() # installation of browser @@ -42,6 +40,7 @@ class Server(socketserver.TCPServer): browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=options) print("finished webdriver installation \n") browser.maximize_window() +browser.implicitly_wait(10); try: # retrieve and wait until page is fully loaded and rendered @@ -62,8 +61,8 @@ class Server(socketserver.TCPServer): panel = browser.find_element(By.CLASS_NAME, "panel") print("found DOM elements main, sidebar-left, sidebar-right, content and panel") - cleanup(browser, httpd, thread) + cleanup(browser, thread) except Exception as e: - cleanup(browser, httpd, thread) + cleanup(browser, thread) raise e