summaryrefslogtreecommitdiff
path: root/tests/write_fuzz_test.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-15 13:04:01 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-15 13:04:01 +0300
commitdcebf9c7f954a55350b68d0ead1935612c4e2e05 (patch)
tree3eb3e9f6154c6760bcb89a565f8ddc8f8b66cb90 /tests/write_fuzz_test.c
parentbd8222e615134c3ec5e7a07b6b1fa97c9bd4a471 (diff)
Rename the library to wsap_vtcore
ncurses installs <term.h> and defines struct term. In a file that includes both headers, an ncurses TERMINAL * and this library's terminal are silently the same type. The name wsap_vtcore avoids the clash. The public header is now <wsap_vtcore/wsap_vtcore.h>. Every global symbol uses the wsap_vtcore_ prefix, every macro uses WSAP_VTCORE_, and the shared library is libwsap_vtcore.so.0. The default terminal name is now "wsap_vtcore". The ISA override variable is WSAP_VTCORE_ISA. No other behavior changes. The amalgamation writes wsap_vtcore.c and wsap_vtcore.h. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/write_fuzz_test.c')
-rw-r--r--tests/write_fuzz_test.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/tests/write_fuzz_test.c b/tests/write_fuzz_test.c
index 8c1475a..d415c5e 100644
--- a/tests/write_fuzz_test.c
+++ b/tests/write_fuzz_test.c
@@ -1,5 +1,5 @@
/*
- * Differential fuzz test for term_feed. Each seed makes random terminal
+ * Differential fuzz test for wsap_vtcore_feed. Each seed makes random terminal
* output: text, controls, CSI and ESC sequences, raw bytes, and resizes.
* One terminal gets the output in a few large writes; the bulk fast paths
* handle it. A second terminal gets it one byte at a time; the generic
@@ -17,18 +17,18 @@
/* Each terminal has its own snapshot, so cells of both stay readable at
* the same time. */
-static struct term_snapshot *snap_bulk, *snap_bytes;
+static struct wsap_vtcore_snapshot *snap_bulk, *snap_bytes;
/* The code points of a cell's text. A cluster has handles that differ
* between snapshots, so the test compares its code points. */
-static int cell_text(const struct term_snapshot *s, const struct term_cell *cell,
+static int cell_text(const struct wsap_vtcore_snapshot *s, const struct wsap_vtcore_cell *cell,
uint32_t *cps, int cap)
{
- int n = term_snapshot_cluster(s, cell->text, cps, cap);
+ int n = wsap_vtcore_snapshot_cluster(s, cell->text, cps, cap);
return n < cap ? n : cap;
}
-static bool same_cell(const struct term_cell *a, const struct term_cell *b)
+static bool same_cell(const struct wsap_vtcore_cell *a, const struct wsap_vtcore_cell *b)
{
if (a->fg != b->fg || a->bg != b->bg || a->attrs != b->attrs || a->width != b->width)
return false;
@@ -38,24 +38,24 @@ static bool same_cell(const struct term_cell *a, const struct term_cell *b)
return na == nb && memcmp(ta, tb, (size_t)na * sizeof(ta[0])) == 0;
}
-static void assert_same(struct term *bulk, struct term *bytes, int seed, int step)
+static void assert_same(struct wsap_vtcore *bulk, struct wsap_vtcore *bytes, int seed, int step)
{
int cols = tt_cols(bulk), rows = tt_rows(bulk);
int history = tt_history(bulk);
bool same = tt_cursor_x(bulk) == tt_cursor_x(bytes) &&
tt_cursor_y(bulk) == tt_cursor_y(bytes) &&
history == tt_history(bytes);
- term_scroll(bulk, history);
- term_scroll(bytes, history);
+ wsap_vtcore_scroll(bulk, history);
+ wsap_vtcore_scroll(bytes, history);
for (int page = 0; same && page <= history; page += rows) {
- bool copied = term_snapshot_update(snap_bulk, bulk);
- copied &= term_snapshot_update(snap_bytes, bytes);
+ bool copied = wsap_vtcore_snapshot_update(snap_bulk, bulk);
+ copied &= wsap_vtcore_snapshot_update(snap_bytes, bytes);
assert(copied);
for (int y = 0; same && y < rows; y++) {
- const struct term_cell *ra = term_snapshot_row(snap_bulk, y);
- const struct term_cell *rb = term_snapshot_row(snap_bytes, y);
+ const struct wsap_vtcore_cell *ra = wsap_vtcore_snapshot_row(snap_bulk, y);
+ const struct wsap_vtcore_cell *rb = wsap_vtcore_snapshot_row(snap_bytes, y);
for (int x = 0; x < cols; x++) {
- const struct term_cell *a = &ra[x], *b = &rb[x];
+ const struct wsap_vtcore_cell *a = &ra[x], *b = &rb[x];
if (!same_cell(a, b)) {
fprintf(stderr, "seed %d step %d: page %d row %d col %d: "
"bulk %x/%x/%x/%x/%u, bytes %x/%x/%x/%x/%u\n",
@@ -66,11 +66,11 @@ static void assert_same(struct term *bulk, struct term *bytes, int seed, int ste
}
}
}
- term_scroll(bulk, -rows);
- term_scroll(bytes, -rows);
+ wsap_vtcore_scroll(bulk, -rows);
+ wsap_vtcore_scroll(bytes, -rows);
}
- term_scroll_to(bulk, 0);
- term_scroll_to(bytes, 0);
+ wsap_vtcore_scroll_to(bulk, 0);
+ wsap_vtcore_scroll_to(bytes, 0);
if (!same)
fprintf(stderr, "seed %d step %d: cursor %d,%d vs %d,%d, history %d vs %d\n",
seed, step, tt_cursor_x(bulk), tt_cursor_y(bulk),
@@ -85,12 +85,12 @@ int main(int argc, char **argv)
for (int seed = 1; seed <= seeds; seed++) {
rng = 0x9e3779b97f4a7c15ull * (uint64_t)seed;
int cols = 4 + rn(30), rows = 2 + rn(10);
- struct term *bulk = tt_new(cols, rows);
- struct term *bytes = tt_new(cols, rows);
+ struct wsap_vtcore *bulk = tt_new(cols, rows);
+ struct wsap_vtcore *bytes = tt_new(cols, rows);
/* A new terminal can get the address of a freed one, so each seed
* uses new snapshots. */
- snap_bulk = term_snapshot_new();
- snap_bytes = term_snapshot_new();
+ snap_bulk = wsap_vtcore_snapshot_new();
+ snap_bytes = wsap_vtcore_snapshot_new();
assert(bulk && bytes && snap_bulk && snap_bytes);
for (int step = 0; step < 6; step++) {
blen = 0;
@@ -110,10 +110,10 @@ int main(int argc, char **argv)
assert_same(bulk, bytes, seed, step);
}
}
- term_snapshot_free(snap_bulk);
- term_snapshot_free(snap_bytes);
- term_free(bulk);
- term_free(bytes);
+ wsap_vtcore_snapshot_free(snap_bulk);
+ wsap_vtcore_snapshot_free(snap_bytes);
+ wsap_vtcore_free(bulk);
+ wsap_vtcore_free(bytes);
}
return 0;
}