Skip to content

Commit

Permalink
Config: Add assertion to config integer parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alasdair committed Jan 16, 2025
1 parent 2d6d09b commit 21a3ad9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/json/sail_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ void sail_config_unwrap_string(sail_string *str, const sail_config_json config)
void sail_config_unwrap_int(sail_int *n, const sail_config_json config)
{
cJSON *json = (cJSON *)config;
mpz_set_str(*n, json->valuestring, 10);
if (mpz_set_str(*n, json->valuestring, 10) == -1) {
sail_assert(false, "Failed to parse integer from configuration");
}
}

void sail_config_truncate(lbits *rop) {
Expand Down
4 changes: 3 additions & 1 deletion test/sailtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
parser.add_argument("--hide-error-output", help="Hide error information.", action='store_true')
parser.add_argument("--compact", help="Compact output.", action='store_true')
parser.add_argument("--targets", help="Targets to use (where supported).", action='append')
parser.add_argument("--test", help="Run only specified test.", action='append')
args = parser.parse_args()

def is_compact():
Expand Down Expand Up @@ -81,7 +82,8 @@ def chunks(filenames, cores):
ys = []
chunk = []
for filename in filenames:
if re.match('.+\.sail$', filename):
basename = os.path.splitext(os.path.basename(filename))[0]
if re.match('.+\.sail$', filename) and (not args.test or basename in args.test):
chunk.append(filename)
if len(chunk) >= cores:
ys.append(list(chunk))
Expand Down

0 comments on commit 21a3ad9

Please sign in to comment.