From abb0cf4721a5b84508edc68988f71c9bf2f9ea38 Mon Sep 17 00:00:00 2001 From: Aryaz Eghbali Date: Wed, 6 Nov 2024 14:44:18 +0100 Subject: [PATCH] Updated tutorial --- tutorial/README.md | 2 ++ tutorial/task1/main.py | 4 ++-- .../src/tutorial_analyses/BranchCoverageAnalysis.py | 4 ++-- .../src/tutorial_analyses/CallGraphAnalysis.py | 4 ++-- .../src/tutorial_analyses/SlowStringConcatAnalysis.py | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tutorial/README.md b/tutorial/README.md index 6697c76..a3feb39 100644 --- a/tutorial/README.md +++ b/tutorial/README.md @@ -18,6 +18,8 @@ To isolate the packages that you install during this tutorial either [use Docker 2. Build the image: `docker build -t dynapyt_tutorial .` 3. Run bash in the container: `docker run -it dynapyt_tutorial /bin/bash` +Note: Changing the code in your host machine does not change the code inside the container. So you either need to share the directory using `-v` option when running docker (`-v .:/dynapyt/`), or repeat steps 2 and 3 each time you modify or implement an analysis. + ### Virtual Environment 1. Install virtual environment: - With pipx: `pipx install virtualenv` diff --git a/tutorial/task1/main.py b/tutorial/task1/main.py index d83d82a..a0fb7fe 100644 --- a/tutorial/task1/main.py +++ b/tutorial/task1/main.py @@ -1,5 +1,5 @@ a = 1 b = 2 c = a + b -if c > 3: - print("c > 3") +if c >= 3: + print("c >= 3") diff --git a/tutorial/tutorial-analyses/src/tutorial_analyses/BranchCoverageAnalysis.py b/tutorial/tutorial-analyses/src/tutorial_analyses/BranchCoverageAnalysis.py index ded9f7b..f6dd0e3 100644 --- a/tutorial/tutorial-analyses/src/tutorial_analyses/BranchCoverageAnalysis.py +++ b/tutorial/tutorial-analyses/src/tutorial_analyses/BranchCoverageAnalysis.py @@ -3,8 +3,8 @@ class BranchCoverageAnalysis(BaseAnalysis): - def __init__(self): - super().__init__() + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) self.branches = {} def enter_control_flow(self, dyn_ast: str, iid: int, cond_value: bool): diff --git a/tutorial/tutorial-analyses/src/tutorial_analyses/CallGraphAnalysis.py b/tutorial/tutorial-analyses/src/tutorial_analyses/CallGraphAnalysis.py index 5d543d5..86a67f9 100644 --- a/tutorial/tutorial-analyses/src/tutorial_analyses/CallGraphAnalysis.py +++ b/tutorial/tutorial-analyses/src/tutorial_analyses/CallGraphAnalysis.py @@ -8,8 +8,8 @@ class CallGraphAnalysis(BaseAnalysis): - def __init__(self): - super(CallGraphAnalysis, self).__init__() + def __init__(self, *args, **kwargs): + super(CallGraphAnalysis, self).__init__(*args, **kwargs) logging.basicConfig(filename="dynapyt.json", format="%(message)s", level=logging.INFO) self.graph = {} diff --git a/tutorial/tutorial-analyses/src/tutorial_analyses/SlowStringConcatAnalysis.py b/tutorial/tutorial-analyses/src/tutorial_analyses/SlowStringConcatAnalysis.py index dcd9d56..440e7b4 100644 --- a/tutorial/tutorial-analyses/src/tutorial_analyses/SlowStringConcatAnalysis.py +++ b/tutorial/tutorial-analyses/src/tutorial_analyses/SlowStringConcatAnalysis.py @@ -3,8 +3,8 @@ class SlowStringConcatAnalysis(BaseAnalysis): - def __init__(self): - super().__init__() + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) self.in_loop = [] self.concat_count = [] self.threshold = 5