This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository terminology.
View the commit online.
commit c58c87f293184a6c1553873fdb8c2f067ed6d876
Author: Boris Faure <[email protected]>
AuthorDate: Sat Aug 22 14:31:37 2026 +0200
tytest: add --chunk=N to replay input in small reads
---
src/bin/tytest.c | 26 ++++++++++++++++++++++++--
src/bin/tytest_common.c | 20 ++++++++++++++++++--
src/bin/tytest_common.h | 1 +
tests/run_tests.sh | 17 ++++++++++++++++-
4 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index c8b402a5..d8b9c2b2 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -212,11 +212,32 @@ _tytest_checksum(Termpty *ty)
}
+static void
+_usage(const char *argv0)
+{
+ fprintf(stderr,
+ "usage: %s read escape codes on stdin, print a state checksum\n"
+ " %s <test>|all run the built-in unit tests\n",
+ argv0, argv0);
+}
+
int
main(int argc, char **argv)
{
- if (argc > 1)
- return _run_tytests(argc, argv);
+ int chunk = 0;
+ int i;
+
+ for (i = 1; i < argc; i++)
+ {
+ if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help"))
+ {
+ _usage(argv[0]);
+ return 0;
+ }
+ else if (!strncmp(argv[i], "--chunk=", 8)) chunk = atoi(argv[i] + 8);
+ /* Anything else is a unit test name, and those take over entirely. */
+ else return _run_tytests(argc, argv);
+ }
eina_init();
emile_init();
@@ -224,6 +245,7 @@ main(int argc, char **argv)
_log_domain = eina_log_domain_register("tytest", NULL);
tytest_common_init();
+ if (chunk > 0) tytest_common_set_chunk(chunk);
tytest_common_main_loop();
diff --git a/src/bin/tytest_common.c b/src/bin/tytest_common.c
index 8101bcef..14edbe93 100644
--- a/src/bin/tytest_common.c
+++ b/src/bin/tytest_common.c
@@ -549,15 +549,31 @@ tytest_common_feed(const char *data, int datalen)
termpty_handle_buf(&_ty, _feed_codepoint, j);
}
+/* How much to take from the fd at a time.
+ *
+ * Adjustable so the suite can replay the same input at different chunk sizes.
+ * Feeding one byte at a time is a brutal test of the carry-over logic: every
+ * escape sequence and every multibyte character then straddles a boundary, and
+ * the result must still be identical to reading in big blocks. */
+static int _read_chunk = 4096;
+
+void
+tytest_common_set_chunk(int chunk)
+{
+ if (chunk > 0) _read_chunk = chunk;
+}
+
void
tytest_common_main_loop(void)
{
char buf[4096];
- int len;
+ int len, want;
+
+ want = (_read_chunk < (int)sizeof(buf)) ? _read_chunk : (int)sizeof(buf);
do
{
- len = read(_ty.fd, buf, sizeof(buf));
+ len = read(_ty.fd, buf, want);
if (len < 0 && errno != EAGAIN)
{
ERR("error while reading from tty slave fd");
diff --git a/src/bin/tytest_common.h b/src/bin/tytest_common.h
index cacfd7db..da74ed85 100644
--- a/src/bin/tytest_common.h
+++ b/src/bin/tytest_common.h
@@ -11,6 +11,7 @@
void tytest_common_main_loop(void);
void tytest_common_feed(const char *data, int datalen);
+void tytest_common_set_chunk(int chunk);
void tytest_common_init(void);
void tytest_common_shutdown(void);
void tytest_common_set_fd(int fd);
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 9fb2d1e4..1ff55d09 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -9,6 +9,7 @@ VERBOSE=0
DEBUG=0
GENRESULTS=0
EXIT_ON_FAILURE=0
+CHUNK=""
NB_TESTS=0
OK_TESTS=0
FAILED_TESTS=0
@@ -72,6 +73,9 @@ where options are:
-r, --results=PATH Path to the result file
-d, --testdir=PATH Path to the test files
-e, --exitonfailure Exit as soon as a test fails
+ -c, --chunk=N Feed tytest N bytes per read, to exercise sequences
+ split across read boundaries. Results must match the
+ default run exactly.
Misc options:
-v, --verbose Be verbose about what is being done
@@ -128,6 +132,13 @@ while [ $# -gt 0 ]; do
-e|-exitonfailure|--exitonfailure)
EXIT_ON_FAILURE=1
;;
+ -c|-chunk|--chunk)
+ if [ -z "$value" ]; then
+ value=$1
+ shift
+ fi
+ CHUNK="--chunk=$value"
+ ;;
*)
echo "Unknown option: $option" 1>&2
;;
@@ -167,7 +178,11 @@ while read -r TEST EXPECTED_CHECKSUMS; do
if [ $VERBOSE -ne 0 ]; then
printf "%s... " "$TEST"
fi
- TEST_CHECKSUM=$("$TESTDIR"/"$TEST" | "$TYTEST")
+ if [ -n "$CHUNK" ]; then
+ TEST_CHECKSUM=$("$TESTDIR"/"$TEST" | "$TYTEST" "$CHUNK")
+ else
+ TEST_CHECKSUM=$("$TESTDIR"/"$TEST" | "$TYTEST")
+ fi
if [ $DEBUG -ne 0 ]; then
printf "(got %s, expected %s) " "$TEST_CHECKSUM" "$EXPECTED_CHECKSUMS"
fi
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.