Files
RedBear-OS/recipes/tests/stdlib/getsubopt.c
T
vasilito b9874d0941 feat: USB storage read/write proof + full Red Bear OS tree sync
Add redbear-usb-storage-check in-guest binary that validates USB mass
storage read and write I/O: discovers /scheme/disk/ devices, writes a
test pattern to sector 2048, reads it back, verifies match, restores
original content. Updates test-usb-storage-qemu.sh with write-proof
verification step.

Includes all accumulated Red Bear OS work: kernel patches, relibc
patches, driver infrastructure, DRM/GPU, KDE recipes, firmware,
validation tooling, build system hardening, and documentation.
2026-05-03 23:03:24 +01:00

56 lines
1.6 KiB
C

#include "test_helpers.h"
int main(void) {
char *const tokens[] = {
"ro",
"rw",
"foo",
"baz",
NULL
};
// getsubopt modifies the string in-place
char opt_str[] = "ro,foo=bar,bool,baz=,rw";
char *options = opt_str;
char *value = NULL;
int idx;
idx = getsubopt(&options, tokens, &value);
UNEXP_IF(getsubopt, idx, != 0);
if (value != NULL) {
printf("getsubopt failed: expected NULL value for 'ro', got '%s'\n", value);
exit(EXIT_FAILURE);
}
idx = getsubopt(&options, tokens, &value);
UNEXP_IF(getsubopt, idx, != 2);
if (value == NULL || strcmp(value, "bar") != 0) {
printf("getsubopt failed: expected 'bar', got '%s'\n", value ? value : "NULL");
exit(EXIT_FAILURE);
}
idx = getsubopt(&options, tokens, &value);
UNEXP_IF(getsubopt, idx, != -1);
if (value == NULL || strcmp(value, "bool") != 0) {
printf("getsubopt failed: expected 'bool' in value, got '%s'\n", value ? value : "NULL");
exit(EXIT_FAILURE);
}
idx = getsubopt(&options, tokens, &value);
UNEXP_IF(getsubopt, idx, != 3);
if (value == NULL || strcmp(value, "") != 0) {
printf("getsubopt failed: expected empty string value, got '%s'\n", value ? value : "NULL");
exit(EXIT_FAILURE);
}
idx = getsubopt(&options, tokens, &value);
UNEXP_IF(getsubopt, idx, != 1);
if (value != NULL) {
printf("getsubopt failed: expected NULL value for 'rw', got '%s'\n", value);
exit(EXIT_FAILURE);
}
idx = getsubopt(&options, tokens, &value);
UNEXP_IF(getsubopt, idx, != -1);
}