Skip to content

Commit

Permalink
Merge pull request #1116 from goblint/gobview-test
Browse files Browse the repository at this point in the history
Fix GobView Test
  • Loading branch information
stilscher authored Jul 25, 2023
2 parents d371ccc + cbd516e commit cbff5cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
1 change: 0 additions & 1 deletion .github/workflows/locked.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,4 @@ jobs:

- name: Test Gobview
run: |
./goblint --enable gobview tests/regression/00-sanity/01-assert.c
python3 scripts/test-gobview.py
2 changes: 1 addition & 1 deletion docs/user-guide/inspecting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://localhost:8000>
4. Visit <http://localhost:8080>
29 changes: 14 additions & 15 deletions scripts/test-gobview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit cbff5cb

Please sign in to comment.