repo stringlengths 1 152 ⌀ | file stringlengths 14 221 | code stringlengths 501 25k | file_length int64 501 25k | avg_line_length float64 20 99.5 | max_line_length int64 21 134 | extension_type stringclasses 2
values |
|---|---|---|---|---|---|---|
null | systemd-main/src/test/test-lock-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include "fd-util.h"
#include "lock-util.h"
#include "rm-rf.h"
#include "tests.h"
#include "tmpfile-util.h"
TEST(make_lock_file) {
_cleanup_(rm_rf_physical_and_freep) char *t = NULL;
_cleanup_close_ int tfd = -EBADF;
_cleanu... | 1,444 | 37.026316 | 93 | c |
null | systemd-main/src/test/test-logarithm.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "logarithm.h"
#include "tests.h"
TEST(LOG2ULL) {
assert_se(LOG2ULL(0) == 0);
assert_se(LOG2ULL(1) == 0);
assert_se(LOG2ULL(8) == 3);
assert_se(LOG2ULL(9) == 3);
assert_se(LOG2ULL(15) == 3);
assert_se(LOG2ULL(16) ... | 2,926 | 29.489583 | 90 | c |
null | systemd-main/src/test/test-loopback.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sched.h>
#include <stdio.h>
#include <string.h>
#include "errno-util.h"
#include "log.h"
#include "loopback-setup.h"
#include "tests.h"
TEST_RET(loopback_setup) {
int r;
if (unshare(CLONE_NEWUSER | CLONE_NEWNET) < 0) {
if (ER... | 1,250 | 26.8 | 100 | c |
null | systemd-main/src/test/test-manager.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "manager.h"
#include "tests.h"
TEST(manager_taint_string) {
Manager m = {};
_cleanup_free_ char *a = manager_taint_string(&m);
assert_se(a);
log_debug("taint string w/o split-usr: '%s'", a);
/* split-usr is the only one... | 954 | 30.833333 | 92 | c |
null | systemd-main/src/test/test-math-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <float.h>
#include "math-util.h"
#include "tests.h"
TEST(iszero_safe) {
/* zeros */
assert_se(iszero_safe(0.0));
assert_se(iszero_safe(-0.0));
assert_se(iszero_safe(0e0));
assert_se(iszero_safe(-0e0));
assert_se... | 4,185 | 36.711712 | 97 | c |
null | systemd-main/src/test/test-memfd-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include "errno-util.h"
#include "fd-util.h"
#include "memfd-util.h"
#include "string-util.h"
#include "tests.h"
TEST(memfd_get_sealed) {
#define TEST_TEXT "this is some random test text we are going to write to a memfd"
_cleanup_close_ int... | 899 | 28.032258 | 107 | c |
null | systemd-main/src/test/test-memory-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "memory-util.h"
#include "tests.h"
TEST(eqzero) {
const uint32_t zeros[] = {0, 0, 0};
const uint32_t ones[] = {1, 1};
const uint32_t mixed[] = {0, 1, 0, 0, 0};
const uint8_t longer[] = {[55] = 255};
assert_se(eqzero(zer... | 1,479 | 25.428571 | 99 | c |
null | systemd-main/src/test/test-mempool.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "mempool.h"
#include "random-util.h"
#include "tests.h"
struct element {
uint64_t value;
};
DEFINE_MEMPOOL(test_mempool, struct element, 8);
TEST(mempool_trim) {
#define NN 4000
struct element *a[NN];
size_t n_freed = 0;
ass... | 2,516 | 26.064516 | 105 | c |
null | systemd-main/src/test/test-mkdir.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include "capability-util.h"
#include "fs-util.h"
#include "mkdir.h"
#include "path-util.h"
#include "process-util.h"
#include "rm-rf.h"
#include "stat-util.h"
#include "tests.h"
#include "tmpfile-util.h"
#include "user-util.h"
TEST(mkdir_p_safe) {... | 5,430 | 37.246479 | 111 | c |
null | systemd-main/src/test/test-memstream-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "memstream-util.h"
#include "string-util.h"
#include "tests.h"
TEST(memstream_done) {
_cleanup_(memstream_done) MemStream m = {};
assert_se(memstream_init(&m));
}
TEST(memstream_empty) {
_cleanup_(memstream_done) MemStream m = {};
... | 1,594 | 25.147541 | 58 | c |
null | systemd-main/src/test/test-modhex.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "recovery-key.h"
#include "alloc-util.h"
#include "string-util.h"
#include "tests.h"
static void test_normalize_recovery_key(const char *t, const char *expected) {
_cleanup_free_ char *z = NULL;
int r;
assert_se(t);
r = normal... | 2,723 | 51.384615 | 117 | c |
null | systemd-main/src/test/test-net-naming-scheme.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "netif-naming-scheme.h"
#include "string-util.h"
#include "tests.h"
TEST(default_net_naming_scheme) {
const NamingScheme *n;
assert_se(n = naming_scheme_from_name(DEFAULT_NET_NAMING_SCHEME));
log_info("default → %s", n->name);
}
TEST(n... | 610 | 25.565217 | 74 | c |
null | systemd-main/src/test/test-netlink-manual.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <arpa/inet.h>
#include <linux/if_tunnel.h>
#include <linux/ip.h>
#include <sys/types.h>
#include <unistd.h>
#include "sd-netlink.h"
#include "macro.h"
#include "module-util.h"
#include "tests.h"
static int load_module(const char *mod_name) {
_cleanup... | 4,018 | 30.645669 | 91 | c |
null | systemd-main/src/test/test-nss-hosts.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <net/if.h>
#include <stdlib.h>
#include <unistd.h>
#include "af-list.h"
#include "alloc-util.h"
#include "dlfcn-util.h"
#include "env-util.h"
#include "errno-list.h"
#include "format-util.h"
#include "hexdecoct.h"
#include "hostname-util.h"
#include "in-addr-u... | 18,650 | 36.908537 | 116 | c |
null | systemd-main/src/test/test-nss-users.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <pwd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include "alloc-util.h"
#include "dlfcn-util.h"
#include "errno-list.h"
#include "format-util.h"
#include "log.h"
#include "main-func.h"
#include "nss-test-util.h"
#include "nss-util.h"
#in... | 8,439 | 31.840467 | 97 | c |
null | systemd-main/src/test/test-nulstr-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "nulstr-util.h"
#include "set.h"
#include "strv.h"
#include "tests.h"
TEST(strv_split_nulstr) {
_cleanup_strv_free_ char **l = NULL;
const char nulstr[] = "str0\0str1\0str2\0str3\0";
l = strv_split_nulstr(nulstr... | 7,755 | 40.924324 | 114 | c |
null | systemd-main/src/test/test-open-file.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "open-file.h"
#include "string-util.h"
#include "tests.h"
TEST(open_file_parse) {
_cleanup_(open_file_freep) OpenFile *of = NULL;
int r;
r = open_file_parse("/proc/1/ns/mnt:host-mount-namespace:read-only", &of);
assert_se(r >=... | 5,792 | 30.145161 | 92 | c |
null | systemd-main/src/test/test-ordered-set.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdio.h>
#include "ordered-set.h"
#include "string-util.h"
#include "strv.h"
#include "tests.h"
TEST(set_steal_first) {
_cleanup_ordered_set_free_ OrderedSet *m = NULL;
int seen[3] = {};
char *val;
m = ordered_set_new(&string... | 3,730 | 32.017699 | 125 | c |
null | systemd-main/src/test/test-os-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include "fileio.h"
#include "fs-util.h"
#include "log.h"
#include "mkdir.h"
#include "os-util.h"
#include "path-util.h"
#include "rm-rf.h"
#include "string-util.h"
#include "strv.h"
#include "tests.h"
#include "tmpfile-util.h"
TEST(path_is_os_tree) ... | 5,515 | 39.558824 | 127 | c |
null | systemd-main/src/test/test-parse-argument.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <signal.h>
#include "parse-argument.h"
#include "stdio-util.h"
#include "tests.h"
TEST(parse_json_argument) {
JsonFormatFlags flags = JSON_FORMAT_PRETTY;
assert_se(parse_json_argument("help", &flags) == 0);
assert_se(flags == JSON_FOR... | 1,502 | 26.833333 | 66 | c |
null | systemd-main/src/test/test-parse-helpers.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/in.h>
#include <sys/socket.h>
#include <stdio.h>
#include "macro.h"
#include "parse-helpers.h"
#include "tests.h"
static void test_valid_item(
const char *str,
int expected_af,
int expected_ip_protocol,
... | 3,802 | 38.614583 | 99 | c |
null | systemd-main/src/test/test-path-lookup.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdlib.h>
#include <sys/stat.h>
#include "log.h"
#include "path-lookup.h"
#include "rm-rf.h"
#include "string-util.h"
#include "strv.h"
#include "tests.h"
#include "tmpfile-util.h"
static void test_paths_one(RuntimeScope scope) {
_cleanup_(rm_rf_phys... | 5,065 | 38.889764 | 100 | c |
null | systemd-main/src/test/test-path.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "alloc-util.h"
#include "all-units.h"
#include "fd-util.h"
#include "fs-util.h"
#include "macro.h"
#include "manager.h"
#include "mkdir.h"
#include "path-util.h"
#include "rm-rf.h"
#include "str... | 13,897 | 32.73301 | 118 | c |
null | systemd-main/src/test/test-percent-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "percent-util.h"
#include "tests.h"
#include "time-util.h"
TEST(parse_percent) {
assert_se(parse_percent("") == -EINVAL);
assert_se(parse_percent("foo") == -EINVAL);
assert_se(parse_percent("0") == -EINVAL);
assert_se(parse_perc... | 9,404 | 46.025 | 112 | c |
null | systemd-main/src/test/test-pretty-print.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "alloc-util.h"
#include "macro.h"
#include "pretty-print.h"
#include "strv.h"
#include "tests.h"
TEST(terminal_urlify) {
_cleanup_free_ char *formatted = NULL;
... | 1,498 | 27.826923 | 125 | c |
null | systemd-main/src/test/test-prioq.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdlib.h>
#include "alloc-util.h"
#include "prioq.h"
#include "set.h"
#include "siphash24.h"
#include "sort-util.h"
#include "tests.h"
#define SET_SIZE 1024*4
static int unsigned_compare(const unsigned *a, const unsigned *b) {
return CMP(*a, *b);
}
... | 3,437 | 26.725806 | 77 | c |
null | systemd-main/src/test/test-procfs-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include "errno-util.h"
#include "format-util.h"
#include "log.h"
#include "procfs-util.h"
#include "process-util.h"
#include "tests.h"
int main(int argc, char *argv[]) {
nsec_t nsec;
uint64_t v, pid_max, threads_max, limit;
... | 2,557 | 31.794872 | 88 | c |
null | systemd-main/src/test/test-qrcode-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "locale-util.h"
#include "main-func.h"
#include "qrcode-util.h"
#include "tests.h"
static int run(int argc, char **argv) {
int r;
test_setup_logging(LOG_DEBUG);
assert_se(setenv("SYSTEMD_COLORS", "1", 1) == 0); /* Force the qrcode to ... | 635 | 25.5 | 94 | c |
null | systemd-main/src/test/test-random-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <math.h>
#include "hexdecoct.h"
#include "log.h"
#include "memory-util.h"
#include "random-util.h"
#include "terminal-util.h"
#include "tests.h"
TEST(random_bytes) {
uint8_t buf[16] = {};
for (size_t i = 1; i < sizeof buf; i++) {
... | 2,425 | 29.325 | 104 | c |
null | systemd-main/src/test/test-ratelimit.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include "macro.h"
#include "ratelimit.h"
#include "tests.h"
#include "time-util.h"
TEST(ratelimit_below) {
int i;
RateLimit ratelimit = { 1 * USEC_PER_SEC, 10 };
for (i = 0; i < 10; i++)
assert_se(ratelimit... | 1,284 | 28.204545 | 66 | c |
null | systemd-main/src/test/test-replace-var.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdio.h>
#include "macro.h"
#include "replace-var.h"
#include "string-util.h"
#include "tests.h"
static char *lookup(const char *variable, void *userdata) {
return strjoin("<<<", variable, ">>>");
}
TEST(replace_var) {
char *r;
asse... | 768 | 22.30303 | 106 | c |
null | systemd-main/src/test/test-rm-rf.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include "alloc-util.h"
#include "process-util.h"
#include "rm-rf.h"
#include "string-util.h"
#include "tests.h"
#include "tmpfile-util.h"
static void test_rm_rf_chmod_inner(void) {
_cleanup_(rm_rf_physical_and_freep) char *d = NULL;
... | 3,599 | 30.304348 | 117 | c |
null | systemd-main/src/test/test-sbat.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
/* We include efi_config.h after undefining PROJECT_VERSION which is also defined in config.h. */
#undef PROJECT_VERSION
#include "efi_config.h"
#include "build.h"
#include "sbat.h"
#include "tests.h"
TEST(sbat_section_text) {
log_info("---SBAT-----------&<---... | 607 | 24.333333 | 97 | c |
null | systemd-main/src/test/test-sched-prio.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
/***
Copyright © 2012 Holger Hans Peter Freyther
***/
#include <sched.h>
#include "all-units.h"
#include "macro.h"
#include "manager.h"
#include "rm-rf.h"
#include "tests.h"
int main(int argc, char *argv[]) {
_cleanup_(rm_rf_physical_and_freep) char *runtime... | 3,010 | 35.719512 | 107 | c |
null | systemd-main/src/test/test-sd-hwdb.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-hwdb.h"
#include "alloc-util.h"
#include "errno-util.h"
#include "errno.h"
#include "hwdb-internal.h"
#include "nulstr-util.h"
#include "tests.h"
TEST(failed_enumerate) {
_cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL;
const char *key, *va... | 2,479 | 27.837209 | 83 | c |
null | systemd-main/src/test/test-sd-path.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-path.h"
#include "alloc-util.h"
#include "string-util.h"
#include "strv.h"
#include "tests.h"
TEST(sd_path_lookup) {
for (uint64_t i = 0; i < _SD_PATH_MAX; i++) {
_cleanup_free_ char *t = NULL, *s = NULL;
int r;
... | 1,864 | 30.083333 | 74 | c |
null | systemd-main/src/test/test-secure-bits.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include "securebits-util.h"
#include "strv.h"
#include "tests.h"
#include "unit-file.h"
static const char * const string_bits[] = {
"keep-caps",
"keep-caps-locked",
"no-setuid-fixup",
"no-setuid-fixup-locked",
... | 3,283 | 32.510204 | 89 | c |
null | systemd-main/src/test/test-selinux.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/stat.h>
#include "alloc-util.h"
#include "fd-util.h"
#include "log.h"
#include "selinux-util.h"
#include "string-util.h"
#include "tests.h"
#include "time-util.h"
static void test_testing(void) {
bool b;
log_info("============ %s =======... | 2,838 | 26.038095 | 88 | c |
null | systemd-main/src/test/test-serialize.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "escape.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "log.h"
#include "serialize.h"
#include "strv.h"
#include "tests.h"
#include "tmpfile-util.h"
static char long_string[LONG_LINE_MAX+1];
TEST(serialize_item) {
_cleanup_(... | 6,605 | 32.704082 | 84 | c |
null | systemd-main/src/test/test-set-disable-mempool.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <pthread.h>
#include "mempool.h"
#include "process-util.h"
#include "set.h"
#include "tests.h"
#define NUM 100
static void* thread(void *p) {
Set **s = p;
assert_se(s);
assert_se(*s);
assert_se(!is_main_thread());
as... | 1,362 | 22.101695 | 98 | c |
null | systemd-main/src/test/test-set.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "random-util.h"
#include "set.h"
#include "strv.h"
#include "tests.h"
TEST(set_steal_first) {
_cleanup_set_free_ Set *m = NULL;
int seen[3] = {};
char *val;
m = set_new(&string_hash_ops);
assert_se(m);
assert_s... | 13,675 | 32.851485 | 125 | c |
null | systemd-main/src/test/test-sha256.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "hexdecoct.h"
#include "sha256.h"
#include "string-util.h"
#include "tests.h"
static void sha256_process_string(const char *key, struct sha256_ctx *ctx) {
sha256_process_bytes(key, strlen(key), ctx);
}
static void test_sha256_one(const char *key, cons... | 1,773 | 33.784314 | 127 | c |
null | systemd-main/src/test/test-sigbus.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#if HAVE_VALGRIND_VALGRIND_H
# include <valgrind/valgrind.h>
#endif
#include "fd-util.h"
#include "fs-util.h"
#include "memory-util.h"
#include "sigbus.h"
#include "tests.h"
int main(int argc, char *argv[]... | 1,675 | 25.603175 | 82 | c |
null | systemd-main/src/test/test-signal-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include "log.h"
#include "macro.h"
#include "signal-util.h"
#include "stdio-util.h"
#include "string-util.h"
#include "tests.h"
#include "process-util.h"
#define info(sig) log_info(#sig " = " STRINGIFY(sig) " = %d", sig)
TEST(rt_signals) {
... | 6,090 | 33.607955 | 84 | c |
null | systemd-main/src/test/test-siphash24.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "memory-util.h"
#include "siphash24.h"
#include "tests.h"
#define ITERATIONS 10000000ULL
static void test_alignment_one(const uint8_t *in, size_t len, const uint8_t *key) {
struct siphash state = {};
uint64_t out;
unsigned i, j;
... | 4,260 | 38.091743 | 92 | c |
null | systemd-main/src/test/test-sizeof.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sched.h>
#include <stdio.h>
#include <string.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/types.h>
#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>
#include "time-util.h"
/* Print information about various types. Useful whe... | 3,507 | 25.984615 | 73 | c |
null | systemd-main/src/test/test-sleep.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <inttypes.h>
#include <linux/fiemap.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include "efivars.h"
#include "errno-util.h"
#include "fd-util.h"
#include "log.h"
#include "memory-util.h"
#include "sleep-util.h"
#include... | 6,273 | 39.477419 | 105 | c |
null | systemd-main/src/test/test-stat-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <linux/magic.h>
#include <sched.h>
#include <unistd.h>
#include "alloc-util.h"
#include "errno-list.h"
#include "fd-util.h"
#include "fs-util.h"
#include "macro.h"
#include "mountpoint-util.h"
#include "namespace-util.h"
#include "path-util.... | 8,043 | 41.560847 | 131 | c |
null | systemd-main/src/test/test-static-destruct.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "static-destruct.h"
#include "strv.h"
#include "tests.h"
static int foo = 0;
static int bar = 0;
static int baz = 0;
static char *memory = NULL;
static char **strings = NULL;
static size_t n_strings = 0;
static int *integers = NULL;
sta... | 1,926 | 27.338235 | 78 | c |
null | systemd-main/src/test/test-strbuf.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdlib.h>
#include "nulstr-util.h"
#include "strbuf.h"
#include "string-util.h"
#include "strv.h"
#include "tests.h"
static ssize_t add_string(struct strbuf *sb, const char *s) {
return strbuf_add_string(sb, s, strlen(s));
}
TEST(strbuf) {
_... | 2,406 | 31.527027 | 90 | c |
null | systemd-main/src/test/test-strxcpyx.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdio.h>
#include "string-util.h"
#include "strxcpyx.h"
#include "tests.h"
TEST(strpcpy) {
char target[25];
char *s = target;
size_t space_left;
bool truncated;
space_left = sizeof(target);
space_left = strpcp... | 5,889 | 32.465909 | 100 | c |
null | systemd-main/src/test/test-sysctl-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/utsname.h>
#include "sd-id128.h"
#include "errno-util.h"
#include "hostname-util.h"
#include "strv.h"
#include "sysctl-util.h"
#include "tests.h"
static const char* const cases[] = {
"a.b.c", "a/b/c",
"a/b/c", "a/b/c",
"a/b.c/d",... | 2,235 | 28.421053 | 85 | c |
null | systemd-main/src/test/test-tables.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "architecture.h"
#include "automount.h"
#include "cgroup.h"
#include "cgroup-util.h"
#include "compress.h"
#include "condition.h"
#include "confidential-virt.h"
#include "device-private.h"
#include "device.h"
#include "discover-image.h"
#include "execute.h"
#in... | 5,413 | 39.706767 | 81 | c |
null | systemd-main/src/test/test-terminal-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include "alloc-util.h"
#include "fd-util.h"
#include "fs-util.h"
#include "macro.h"
#include "path-util.h"
#include "strv.h"
#include "terminal-util.h"
#include "tests... | 6,190 | 35.633136 | 118 | c |
null | systemd-main/src/test/test-tmpfile-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
#include "fs-util.h"
#include "log.h"
#include "path-util.h"
#include "process-util.h"
#include "string-util.h"
#include "tests.h"
#include "tmpfile-util.h"... | 11,490 | 36.429967 | 119 | c |
null | systemd-main/src/test/test-uid-alloc-range.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include <sys/types.h>
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
#include "fs-util.h"
#include "tests.h"
#include "tmpfile-util.h"
#include "uid-alloc-range.h"
static void test_read_login_defs_one(const char *path) {
... | 3,585 | 37.148936 | 86 | c |
null | systemd-main/src/test/test-uid-range.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stddef.h>
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "tests.h"
#include "tmpfile-util.h"
#include "uid-range.h"
#include "user-util.h"
#include "virt.h"
TEST(uid_range) {
_cl... | 6,329 | 34.965909 | 106 | c |
null | systemd-main/src/test/test-unaligned.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "memory-util.h"
#include "sparse-endian.h"
#include "tests.h"
#include "unaligned.h"
static uint8_t data[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
};
TEST(be) {
uint8_t scratc... | 7,454 | 43.112426 | 118 | c |
null | systemd-main/src/test/test-unit-file.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "initrd-util.h"
#include "path-lookup.h"
#include "set.h"
#include "special.h"
#include "strv.h"
#include "tests.h"
#include "unit-file.h"
TEST(unit_validate_alias_symlink_and_warn) {
assert_se(unit_validate_alias_symlink_or_warn(LOG_INFO, "/path/a.ser... | 5,202 | 45.873874 | 122 | c |
null | systemd-main/src/test/test-user-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "format-util.h"
#include "libcrypt-util.h"
#include "log.h"
#include "macro.h"
#include "memory-util.h"
#include "path-util.h"
#include "string-util.h"
#include "tests.h"
#include "user-util.h"
static void test_uid_to_name_one(uid_t uid... | 21,686 | 43.531828 | 130 | c |
null | systemd-main/src/test/test-utmp.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "format-util.h"
#include "socket-util.h"
#include "stdio-util.h"
#include "string-util.h"
#include "utmp-wtmp.h"
#include "tests.h"
#ifndef UT_LINESIZE
# define UT_LINESIZE 32
#endif
#ifndef UT_NAMESIZE
# define UT_NAMESIZE 32
#endif
#ifndef UT_HOS... | 2,218 | 36.610169 | 109 | c |
null | systemd-main/src/test/test-verbs.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <getopt.h>
#include "macro.h"
#include "strv.h"
#include "tests.h"
#include "verbs.h"
static int noop_dispatcher(int argc, char *argv[], void *userdata) {
return 0;
}
#define test_dispatch_one(argv, verbs, expected) \
optind = 0; \
as... | 2,052 | 33.216667 | 101 | c |
null | systemd-main/src/test/test-watch-pid.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "log.h"
#include "manager.h"
#include "rm-rf.h"
#include "service.h"
#include "tests.h"
int main(int argc, char *argv[]) {
_cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL;
_cleanup_(manager_freep) Manager *m = NULL;
Unit *a... | 2,989 | 31.857143 | 84 | c |
null | systemd-main/src/test/test-watchdog.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <string.h>
#include <unistd.h>
#include "log.h"
#include "tests.h"
#include "watchdog.h"
int main(int argc, char *argv[]) {
usec_t t;
unsigned i, count;
int r;
bool slow;
test_setup_logging(LOG_DEBUG);
slow = ... | 978 | 23.475 | 76 | c |
null | systemd-main/src/test/test-web-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "macro.h"
#include "tests.h"
#include "web-util.h"
TEST(is_valid_documentation_url) {
assert_se(documentation_url_is_valid("https://www.freedesktop.org/wiki/Software/systemd"));
assert_se(documentation_url_is_valid("https://www.kernel.org/doc/D... | 980 | 43.590909 | 118 | c |
null | systemd-main/src/test/test-xattr-util.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/xattr.h>
#include <unistd.h>
#include "alloc-util.h"
#include "fd-util.h"
#include "fs-util.h"
#include "macro.h"
#include "rm-rf.h"
#include "string-util.h"
#include "tests.h"
#include "tmpfile... | 4,504 | 33.653846 | 100 | c |
null | systemd-main/src/test/test-xml.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdarg.h>
#include "alloc-util.h"
#include "string-util.h"
#include "xml.h"
static void test_one(const char *data, ...) {
void *state = NULL;
va_list ap;
va_start(ap, data);
for (;;) {
_cleanup_free_ char *na... | 1,663 | 24.212121 | 62 | c |
null | systemd-main/src/test/udev-rule-runner.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
/***
Copyright © 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
***/
#include <errno.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/signalfd.h>
#include <unistd.h>
#include "device-private.h"
#include "fs-util.h"
#inc... | 5,869 | 31.977528 | 118 | c |
null | systemd-main/src/timesync/timesyncd-conf.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "constants.h"
#include "dns-domain.h"
#include "extract-word.h"
#include "string-util.h"
#include "timesyncd-conf.h"
#include "timesyncd-manager.h"
#include "timesyncd-server.h"
int manager_parse_server_string(Manager *m, ServerType typ... | 4,073 | 30.828125 | 123 | c |
null | systemd-main/src/timesync/timesyncd-manager.h | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <sys/timex.h>
#include "sd-bus.h"
#include "sd-event.h"
#include "sd-network.h"
#include "sd-resolve.h"
#include "hashmap.h"
#include "list.h"
#include "ratelimit.h"
#include "time-util.h"
#include "timesyncd-ntp-message.h"
typedef struct Manage... | 3,648 | 25.830882 | 79 | h |
null | systemd-main/src/timesync/timesyncd-ntp-message.h | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sparse-endian.h"
/* NTP protocol, packet header */
#define NTP_LEAP_PLUSSEC 1
#define NTP_LEAP_MINUSSEC 2
#define NTP_LEAP_NOTINSYNC 3
#define NTP_MODE_CLIENT 3
#define NTP_MODE_SERVER ... | 1,276 | 26.76087 | 75 | h |
null | systemd-main/src/timesync/timesyncd-server.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "string-table.h"
#include "timesyncd-server.h"
static const char * const server_type_table[_SERVER_TYPE_MAX] = {
[SERVER_SYSTEM] = "system",
[SERVER_FALLBACK] = "fallback",
[SERVER_LINK] = "link",
[... | 4,151 | 26.137255 | 86 | c |
null | systemd-main/src/timesync/timesyncd-server.h | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "list.h"
#include "socket-util.h"
typedef struct ServerAddress ServerAddress;
typedef struct ServerName ServerName;
typedef enum ServerType {
SERVER_SYSTEM,
SERVER_FALLBACK,
SERVER_LINK,
SERVER_RUNTIME,
_SE... | 1,309 | 24.686275 | 116 | h |
null | systemd-main/src/timesync/wait-sync.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
/* systemd service to wait until kernel realtime clock is synchronized */
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/inotify.h>
#include <sys/timerfd.h>
#include <sys/timex.h>
#include <unistd.h>
#in... | 9,466 | 38.282158 | 123 | c |
null | systemd-main/src/tmpfiles/offline-passwd.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "chase.h"
#include "fd-util.h"
#include "offline-passwd.h"
#include "path-util.h"
#include "user-util.h"
DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR(uid_gid_hash_ops, char, string_hash_func, string_compare_func, free);
static int open_passwd_file(const char *... | 4,682 | 26.710059 | 113 | c |
null | systemd-main/src/tmpfiles/test-offline-passwd.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <getopt.h>
#include "offline-passwd.h"
#include "user-util.h"
#include "format-util.h"
#include "tests.h"
static char *arg_root = NULL;
static void test_resolve_one(const char *name) {
bool relaxed = name || arg_root;
if (!name)
... | 2,324 | 26.034884 | 80 | c |
null | systemd-main/src/tty-ask-password-agent/tty-ask-password-agent.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
/***
Copyright © 2015 Werner Fink
***/
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdbool.h>
#include <stddef.h>
#include <sys/prctl.h>
#include <sys/signalfd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wa... | 23,489 | 32.037975 | 122 | c |
null | systemd-main/src/udev/fuzz-udev-rule-parse-value.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <string.h>
#include "alloc-util.h"
#include "fuzz.h"
#include "udev-util.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_free_ char *str = NULL;
int r;
char *value = UINT_TO_PTR(0x12345678U);
char *en... | 849 | 25.5625 | 62 | c |
null | systemd-main/src/udev/fuzz-udev-rules.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdio.h>
#include "fd-util.h"
#include "fs-util.h"
#include "fuzz.h"
#include "tests.h"
#include "tmpfile-util.h"
#include "udev-rules.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_(udev_rules_freep) UdevRules *rules = NU... | 1,131 | 29.594595 | 85 | c |
null | systemd-main/src/udev/test-udev-builtin.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "tests.h"
#include "udev-builtin.h"
TEST(udev_builtin_cmd_to_ptr) {
/* Those could have been static asserts, but ({}) is not allowed there. */
#if HAVE_BLKID
assert_se(UDEV_BUILTIN_CMD_TO_PTR(UDEV_BUILTIN_BLKID));
assert_se(PTR_TO_UDEV_... | 892 | 41.52381 | 116 | c |
null | systemd-main/src/udev/test-udev-event.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "path-util.h"
#include "signal-util.h"
#include "strv.h"
#include "tests.h"
#include "udev-event.h"
#define BUF_SIZE 1024
static void test_event_spawn_core(bool with_pidfd, const char *cmd, char *result_buf, size_t buf_size) {
_cleanup_(sd_device_unre... | 3,471 | 29.725664 | 115 | c |
null | systemd-main/src/udev/udev-builtin-btrfs.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <fcntl.h>
#include <linux/btrfs.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include "device-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "string-util.h"
#include "strxcpyx.h"
#include "udev-builtin.h"
static int builtin_btrfs(UdevEvent *ev... | 1,864 | 35.568627 | 106 | c |
null | systemd-main/src/udev/udev-builtin-hwdb.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <fnmatch.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include "sd-hwdb.h"
#include "alloc-util.h"
#include "device-util.h"
#include "hwdb-util.h"
#include "parse-util.h"
#include "string-util.h"
#include "udev-builtin.h"
... | 7,072 | 30.02193 | 116 | c |
null | systemd-main/src/udev/udev-builtin-input_id.c | /* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* expose input properties via udev
*
* Portions Copyright © 2004 David Zeuthen, <david@fubar.dk>
* Copyright © 2014 Carlos Garnacho <carlosg@gnome.org>
*/
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
#include <linux/limits.h>
#in... | 18,835 | 42.400922 | 131 | c |
null | systemd-main/src/udev/udev-builtin-net_setup_link.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "device-util.h"
#include "escape.h"
#include "errno-util.h"
#include "link-config.h"
#include "log.h"
#include "string-util.h"
#include "strv.h"
#include "udev-builtin.h"
static LinkConfigContext *ctx = NULL;
static int builtin_net_set... | 3,657 | 30.264957 | 113 | c |
null | systemd-main/src/udev/udev-builtin-uaccess.c | /* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* manage device node user ACL
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "sd-login.h"
#include "device-util.h"
#include "devnode-acl.h"
#include "login-util.h"
#include "log.h"
#include "udev-builtin.h"
static int ... | 2,291 | 26.95122 | 117 | c |
null | systemd-main/src/udev/udev-builtin-usb_id.c | /* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* USB device properties and persistent device path
*
* Copyright (c) 2005 SUSE Linux Products GmbH, Germany
* Author: Hannes Reinecke <hare@suse.de>
*/
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <uni... | 19,121 | 38.02449 | 124 | c |
null | systemd-main/src/udev/udev-builtin.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <getopt.h>
#include <stdio.h>
#include "device-private.h"
#include "device-util.h"
#include "string-util.h"
#include "strv.h"
#include "udev-builtin.h"
static bool initialized;
static const UdevBuiltin *const builtins[_UDEV_BUILTIN_MAX] = {
#if HAVE_BLKID
... | 4,464 | 27.621795 | 107 | c |
null | systemd-main/src/udev/udev-builtin.h | /* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include <stdbool.h>
#include "sd-device.h"
#include "sd-netlink.h"
#include "macro.h"
#include "udev-event.h"
typedef enum UdevBuiltinCommand {
#if HAVE_BLKID
UDEV_BUILTIN_BLKID,
#endif
UDEV_BUILTIN_BTRFS,
UDEV_BUILTIN_HWDB,
... | 2,855 | 31.827586 | 113 | h |
null | systemd-main/src/udev/udev-ctrl.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <poll.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <sys/un.h>
#include <unistd.h>
#include "sd-event.h"
#include "alloc-util.h"
#include "errno-util.h"
#include "fd-util.h"
#include "format-util.h"
#include "io-ut... | 11,212 | 29.889807 | 130 | c |
null | systemd-main/src/udev/udev-ctrl.h | /* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "sd-event.h"
#include "macro.h"
#include "time-util.h"
typedef struct UdevCtrl UdevCtrl;
typedef enum UdevCtrlMessageType {
_UDEV_CTRL_END_MESSAGES,
UDEV_CTRL_SET_LOG_LEVEL,
UDEV_CTRL_STOP_EXEC_QUEUE,
UDEV_CTRL_STA... | 2,586 | 31.746835 | 86 | h |
null | systemd-main/src/udev/udev-event.h | /* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/*
* Copyright © 2003 Greg Kroah-Hartman <greg@kroah.com>
*/
#include "sd-device.h"
#include "sd-netlink.h"
#include "hashmap.h"
#include "macro.h"
#include "udev-rules.h"
#include "udev-util.h"
#define READ_END 0
#define WRITE_END 1
#define UDEV_ALLOW... | 2,409 | 28.036145 | 99 | h |
null | systemd-main/src/udev/udev-node.h | /* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include <stdbool.h>
#include <sys/types.h>
#include "sd-device.h"
#include "hashmap.h"
int udev_node_apply_permissions(
sd_device *dev,
bool apply_mac,
mode_t mode,
uid_t uid,
... | 762 | 24.433333 | 71 | h |
null | systemd-main/src/udev/udev-rules.h | /* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "alloc-util.h"
#include "hashmap.h"
#include "time-util.h"
#include "udev-util.h"
typedef struct UdevRuleFile UdevRuleFile;
typedef struct UdevRules UdevRules;
typedef struct UdevEvent UdevEvent;
typedef enum {
ESCAPE_UNSET,
ESCAPE... | 1,354 | 37.714286 | 105 | h |
null | systemd-main/src/udev/udev-watch.c | /* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright © 2009 Canonical Ltd.
* Copyright © 2009 Scott James Remnant <scott@netsplit.com>
*/
#include <sys/inotify.h>
#include "alloc-util.h"
#include "device-private.h"
#include "device-util.h"
#include "dirent-util.h"
#include "fd-util.h"
#include "fs-util.h... | 9,035 | 33.62069 | 128 | c |
null | systemd-main/src/udev/udevadm-control.c | /* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This progra... | 8,693 | 45.741935 | 128 | c |
null | systemd-main/src/udev/udevadm-hwdb.c | /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <getopt.h>
#include "hwdb-util.h"
#include "udevadm.h"
static const char *arg_test = NULL;
static const char *arg_root = NULL;
static const char *arg_hwdb_bin_dir = NULL;
static bool arg_update = false;
static bool arg_strict = false;
static int help(void) {... | 3,457 | 32.572816 | 104 | c |
null | systemd-main/src/udev/udevadm-monitor.c | /* SPDX-License-Identifier: GPL-2.0-or-later */
#include <errno.h>
#include <getopt.h>
#include "sd-device.h"
#include "sd-event.h"
#include "alloc-util.h"
#include "device-monitor-private.h"
#include "device-private.h"
#include "device-util.h"
#include "fd-util.h"
#include "format-util.h"
#include "hashmap.h"
#incl... | 8,980 | 35.068273 | 108 | c |
null | systemd-main/src/udev/udevadm-settle.c | /* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright © 2009 Canonical Ltd.
* Copyright © 2009 Scott James Remnant <scott@netsplit.com>
*/
#include <getopt.h>
#include <unistd.h>
#include "sd-bus.h"
#include "sd-event.h"
#include "sd-login.h"
#include "sd-messages.h"
#include "bus-util.h"
#include "path-... | 9,146 | 35.15415 | 121 | c |
null | systemd-main/src/udev/udevadm-test-builtin.c | /* SPDX-License-Identifier: GPL-2.0-or-later */
#include <errno.h>
#include <getopt.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "log.h"
#include "udev-builtin.h"
#include "udevadm.h"
#include "udevadm-util.h"
static sd_device_action_t arg_action = SD_DEVICE_ADD;
static const char *arg_comm... | 3,468 | 29.429825 | 98 | c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.