mirror of
https://github.com/eunomia-bpf/bpf-developer-tutorial.git
synced 2026-10-31 20:54:56 +08:00
Reject empty fsession CLI values
This commit is contained in:
@@ -63,7 +63,7 @@ static int parse_u64(const char *value, unsigned long long maximum,
|
|||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
parsed = strtoull(value, &end, 10);
|
parsed = strtoull(value, &end, 10);
|
||||||
if (errno || !end || *end || parsed > maximum)
|
if (errno || end == value || *end || parsed > maximum)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
*result = parsed;
|
*result = parsed;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -101,6 +101,16 @@ def main() -> int:
|
|||||||
assert invalid.returncode != 0
|
assert invalid.returncode != 0
|
||||||
assert "invalid duration" in invalid.stdout
|
assert "invalid duration" in invalid.stdout
|
||||||
|
|
||||||
|
empty_threshold = subprocess.run(
|
||||||
|
[binary, "--threshold-us", ""],
|
||||||
|
text=True,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT,
|
||||||
|
check=False,
|
||||||
|
)
|
||||||
|
assert empty_threshold.returncode != 0
|
||||||
|
assert "invalid threshold" in empty_threshold.stdout
|
||||||
|
|
||||||
pid = str(os.getpid())
|
pid = str(os.getpid())
|
||||||
missed, _ = run_trace(
|
missed, _ = run_trace(
|
||||||
binary,
|
binary,
|
||||||
|
|||||||
Reference in New Issue
Block a user