• Andrey Ignatov's avatar
    selftests/bpf: Test bpf_strtol and bpf_strtoul helpers · 8549ddc8
    Andrey Ignatov authored
    Test that bpf_strtol and  bpf_strtoul helpers can be used to convert
    provided buffer to long or unsigned long correspondingly and return both
    correct result and number of consumed bytes, or proper errno.
    
    Example of output:
      # ./test_sysctl
      ..
      Test case: bpf_strtoul one number string .. [PASS]
      Test case: bpf_strtoul multi number string .. [PASS]
      Test case: bpf_strtoul buf_len = 0, reject .. [PASS]
      Test case: bpf_strtoul supported base, ok .. [PASS]
      Test case: bpf_strtoul unsupported base, EINVAL .. [PASS]
      Test case: bpf_strtoul buf with spaces only, EINVAL .. [PASS]
      Test case: bpf_strtoul negative number, EINVAL .. [PASS]
      Test case: bpf_strtol negative number, ok .. [PASS]
      Test case: bpf_strtol hex number, ok .. [PASS]
      Test case: bpf_strtol max long .. [PASS]
      Test case: bpf_strtol overflow, ERANGE .. [PASS]
      Summary: 36 PASSED, 0 FAILED
    Signed-off-by: default avatarAndrey Ignatov <rdna@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    8549ddc8
test_sysctl.c 37.1 KB