Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/tools/testing/selftests/bpf/progs/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 2 kB image not shown  

Quelle  string_kfuncs_success.c

  Sprache: C
 

// SPDX-License-Identifier: GPL-2.0
/* Copyright (C) 2025 Red Hat, Inc.*/
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"
#include "errno.h"

char str[] = "hello world";

#define __test(retval) SEC("syscall") __success __retval(retval)

/* Functional tests */
__test(0int test_strcmp_eq(void *ctx) { return bpf_strcmp(str, "hello world"); }
__test(1int test_strcmp_neq(void *ctx) { return bpf_strcmp(str, "hello"); }
__test(1int test_strchr_found(void *ctx) { return bpf_strchr(str, 'e'); }
__test(11int test_strchr_null(void *ctx) { return bpf_strchr(str, '\0'); }
__test(-ENOENT) int test_strchr_notfound(void *ctx) { return bpf_strchr(str, 'x'); }
__test(1int test_strchrnul_found(void *ctx) { return bpf_strchrnul(str, 'e'); }
__test(11int test_strchrnul_notfound(void *ctx) { return bpf_strchrnul(str, 'x'); }
__test(1int test_strnchr_found(void *ctx) { return bpf_strnchr(str, 5'e'); }
__test(11int test_strnchr_null(void *ctx) { return bpf_strnchr(str, 12'\0'); }
__test(-ENOENT) int test_strnchr_notfound(void *ctx) { return bpf_strnchr(str, 5'w'); }
__test(9int test_strrchr_found(void *ctx) { return bpf_strrchr(str, 'l'); }
__test(11int test_strrchr_null(void *ctx) { return bpf_strrchr(str, '\0'); }
__test(-ENOENT) int test_strrchr_notfound(void *ctx) { return bpf_strrchr(str, 'x'); }
__test(11int test_strlen(void *ctx) { return bpf_strlen(str); }
__test(11int test_strnlen(void *ctx) { return bpf_strnlen(str, 12); }
__test(5int test_strspn(void *ctx) { return bpf_strspn(str, "ehlo"); }
__test(2int test_strcspn(void *ctx) { return bpf_strcspn(str, "lo"); }
__test(6int test_strstr_found(void *ctx) { return bpf_strstr(str, "world"); }
__test(-ENOENT) int test_strstr_notfound(void *ctx) { return bpf_strstr(str, "hi"); }
__test(0int test_strstr_empty(void *ctx) { return bpf_strstr(str, ""); }
__test(0int test_strnstr_found1(void *ctx) { return bpf_strnstr(""""0); }
__test(0int test_strnstr_found2(void *ctx) { return bpf_strnstr(str, "hello"5); }
__test(0int test_strnstr_found3(void *ctx) { return bpf_strnstr(str, "hello"6); }
__test(-ENOENT) int test_strnstr_notfound1(void *ctx) { return bpf_strnstr(str, "hi"10); }
__test(-ENOENT) int test_strnstr_notfound2(void *ctx) { return bpf_strnstr(str, "hello"4); }
__test(-ENOENT) int test_strnstr_notfound3(void *ctx) { return bpf_strnstr("""a"0); }
__test(0int test_strnstr_empty(void *ctx) { return bpf_strnstr(str, ""1); }

char _license[] SEC("license") = "GPL";

Messung V0.5 in Prozent
C=95 H=90 G=92

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-06) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.