aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/args.py6
-rw-r--r--src/philo/log.py9
-rw-r--r--src/philo/philo.py10
-rw-r--r--src/suite.py35
-rw-r--r--src/test.py3
5 files changed, 29 insertions, 34 deletions
diff --git a/src/args.py b/src/args.py
index 2cb5749..8fb9b5f 100644
--- a/src/args.py
+++ b/src/args.py
@@ -6,7 +6,7 @@
# By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/10/01 10:23:09 by cacharle #+# #+# #
-# Updated: 2020/10/05 14:03:42 by cacharle ### ########.fr #
+# Updated: 2021/01/03 13:32:55 by cacharle ### ########.fr #
# #
# ############################################################################ #
@@ -44,9 +44,9 @@ def parse_args():
- 3: philo_three
- 0: all programs
"""),
- required=True,
type=int,
- choices=[0, 1, 2, 3]
+ choices=[0, 1, 2, 3],
+ default=0
)
parser.add_argument(
"-b", "--build",
diff --git a/src/philo/log.py b/src/philo/log.py
index a07b734..8094688 100644
--- a/src/philo/log.py
+++ b/src/philo/log.py
@@ -6,7 +6,7 @@
# By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/10/01 10:51:39 by cacharle #+# #+# #
-# Updated: 2020/10/05 13:52:51 by cacharle ### ########.fr #
+# Updated: 2021/01/03 13:28:20 by cacharle ### ########.fr #
# #
# ############################################################################ #
@@ -29,15 +29,14 @@ class Log:
self._line = line
self.id = self._parse_ranged_int(match.group("id"), 1, philo_num)
- self.timestamp = self._parse_ranged_int(
- match.group("timestamp"), start_time, end_time)
+ self.timestamp = self._parse_ranged_int(match.group("timestamp"))
self.event = Event.from_string(match.group('event'))
- def _parse_ranged_int(self, s, lo, hi):
+ def _parse_ranged_int(self, s, lo=None, hi=None):
try:
value = int(s)
- if not (lo <= value <= hi):
+ if lo is not None and not (lo <= value <= hi):
raise philo.error.Format(
self._line,
"{} should be between {} - {}".format(s, lo, hi)
diff --git a/src/philo/philo.py b/src/philo/philo.py
index 3319a0b..0e62e97 100644
--- a/src/philo/philo.py
+++ b/src/philo/philo.py
@@ -6,7 +6,7 @@
# By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/10/01 10:52:56 by cacharle #+# #+# #
-# Updated: 2020/10/05 14:03:07 by cacharle ### ########.fr #
+# Updated: 2021/01/03 13:31:54 by cacharle ### ########.fr #
# #
# ############################################################################ #
@@ -56,10 +56,10 @@ class Philo:
# check log event number
grouped = [(e, list(g)) for e, g in itertools.groupby(self.logs, (lambda x: x.event))]
for e, g in grouped[:-1]:
- if e is Event.EAT:
- if len(g) != self._meal_num:
- self._raise("Should eat {} times".format(self._meal_num))
- elif e is Event.FORK:
+ # if e is Event.EAT:
+ # if len(g) != self._meal_num:
+ # self._raise("Should eat {} times".format(self._meal_num))
+ if e is Event.FORK:
if len(g) != 2:
self._raise("Should take fork 2 times")
elif len(g) != 1:
diff --git a/src/suite.py b/src/suite.py
index dd087e6..a2c5875 100644
--- a/src/suite.py
+++ b/src/suite.py
@@ -6,7 +6,7 @@
# By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/10/01 10:41:43 by cacharle #+# #+# #
-# Updated: 2020/10/05 13:49:30 by cacharle ### ########.fr #
+# Updated: 2021/01/03 13:30:56 by cacharle ### ########.fr #
# #
# ############################################################################ #
@@ -40,21 +40,18 @@ def suite():
Test.new_error(["10", "10", "10", str(-config.UINT_MAX)])
Test.new_error(["10", "10", "10", "10", str(-config.UINT_MAX)])
- Test(0, 100, 10, 10)
- Test(1, 100, 10, 10)
-
- Test(2, 100, 50, 50)
- Test(3, 100, 50, 50)
- Test(4, 100, 50, 50)
- Test(5, 100, 50, 50)
- Test(6, 100, 50, 50)
- Test(7, 100, 50, 50)
-
- # Test(100, 100, 50, 50)
- #
- # Test(10, 100, 100, 10)
- #
- # Test(2, 50, 10, 10)
- # Test(10, 50, 10, 10)
- # Test(10, 100, 10, 10)
- # Test(10, 200, 10, 10)
+ Test(0, 120, 10, 10)
+ Test(1, 120, 10, 10)
+
+ Test(2, 120, 60, 60)
+ Test(3, 120, 60, 60)
+ Test(4, 120, 60, 60)
+ Test(5, 120, 60, 60)
+ Test(6, 120, 60, 60)
+ Test(7, 120, 60, 60)
+
+ Test(4, 410, 200, 200)
+ Test(4, 310, 200, 100)
+
+ Test(5, 800, 200, 200)
+ Test(5, 800, 200, 200, 7)
diff --git a/src/test.py b/src/test.py
index 4312858..b009322 100644
--- a/src/test.py
+++ b/src/test.py
@@ -6,7 +6,7 @@
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/27 11:36:32 by charles #+# #+# #
-# Updated: 2020/10/05 13:50:01 by cacharle ### ########.fr #
+# Updated: 2021/01/03 13:53:38 by cacharle ### ########.fr #
# #
# ############################################################################ #
@@ -89,7 +89,6 @@ class Test:
try:
out, err = process.communicate(timeout=config.TIMEOUT)
- # process.terminate()
except subprocess.TimeoutExpired:
process.kill()
out, err = process.communicate()