Files
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

61 lines
1.1 KiB
C

#include <assert.h>
#include <stdio.h>
#include <wchar.h>
int test_initial_orientation(void) {
FILE *f = tmpfile();
assert(fwide(f, 0) == 0);
return 0;
}
int test_manual_byte_orientation(void) {
FILE *f = tmpfile();
// set manually to byte orientation
assert(fwide(f, -483) == -1);
// Cannot change to wchar orientation
assert(fwide(f, 1) == -1);
fclose(f);
return 0;
}
int test_manual_wchar_orientation(void) {
FILE *f = tmpfile();
// set manually to wchar orientation
assert(fwide(f, 483) == 1);
// Cannot change to byte orientation
assert(fwide(f, -1) == 1);
fclose(f);
return 0;
}
int test_orientation_after_fprintf(void) {
// open file and write bytes; implicitly setting the bytes orientation
FILE *f = tmpfile();
assert(fprintf(f, "blah\n") == 5);
// Check that bytes orientation is set
assert(fwide(f, 0) == -1);
fclose(f);
return 0;
}
int main() {
int(*tests[])(void) = {
&test_initial_orientation,
&test_manual_byte_orientation,
&test_manual_wchar_orientation,
&test_orientation_after_fprintf,
};
for(size_t i = 0; i < sizeof(tests) / sizeof(int(*)(void)); i++) {
printf("%d\n", (*tests[i])());
}
}