aboutsummaryrefslogtreecommitdiff
path: root/testsuite/awk.tests
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/awk.tests')
-rwxr-xr-xtestsuite/awk.tests116
1 files changed, 116 insertions, 0 deletions
diff --git a/testsuite/awk.tests b/testsuite/awk.tests
index 11beb1b10..0a84dc13e 100755
--- a/testsuite/awk.tests
+++ b/testsuite/awk.tests
@@ -499,4 +499,120 @@ testing 'awk backslash+CRLF eaten with no trace' \
499 'BEGIN { printf "Hello\\\r\n world\\n" }\n' 499 'BEGIN { printf "Hello\\\r\n world\\n" }\n'
500SKIP= 500SKIP=
501 501
502# User-supplied bug (SEGV) example, was causing use-after-realloc
503testing 'awk assign while assign' \
504 "awk '\$5=\$\$5=\$0'; echo \$?" \
505 "\
506─ process timing ────────────────────────────────────┬─ ─ process timing ────────────────────────────────────┬─ overall results ────┐ results ────┐
507│ run time : │ run time : 0 days, 0 hrs, 0 min, 56 sec │ cycles done : 0 │ days, 0 hrs, 0 min, 56 sec │ cycles done : 0 │
508│ last new find │ last new find : 0 days, 0 hrs, 0 min, 1 sec │ corpus count : 208 │ 0 days, 0 hrs, 0 min, 1 sec │ corpus count : 208 │
509│last saved crash : │last saved crash : none seen yet │saved crashes : 0 │ seen yet │saved crashes : 0 │
510│ last saved hang │ last saved hang : none seen yet │ saved hangs : 0 │ none seen yet │ saved hangs : 0 │
511├─ cycle progress ─────────────────────┬─ ├─ cycle progress ─────────────────────┬─ map coverage┴──────────────────────┤ coverage┴──────────────────────┤
512│ now processing : │ now processing : 184.1 (88.5%) │ map density : 0.30% / 0.52% │ (88.5%) │ map density : 0.30% / 0.52% │ │ now processing : 184.1 (88.5%) │ map density : 0.30% / 0.52% │
513│ runs timed out │ runs timed out : 0 (0.00%) │ count coverage : 2.18 bits/tuple │ 0 (0.00%) │ count coverage : 2.18 bits/tuple │
514├─ stage progress ─────────────────────┼─ ├─ stage progress ─────────────────────┼─ findings in depth ─────────────────┤ in depth ─────────────────┤
515│ now trying : │ now trying : havoc │ favored items : 43 (20.67%) │ │ favored items : 43 (20.67%) │
516│ stage execs : │ stage execs : 11.2k/131k (8.51%) │ new edges on : 52 (25.00%) │ (8.51%) │ new edges on │ stage execs : 11.2k/131k (8.51%) │ new edges on : 52 (25.00%) │ 52 (25.00%) │
517│ total execs : │ total execs : 179k │ total crashes : 0 (0 saved) │ │ total crashes : 0 (0 saved) │ │ total execs : 179k │ total crashes : 0 (0 saved) │
518│ exec speed : │ exec speed : 3143/sec │ total tmouts : 0 (0 saved) │ │ total tmouts : 0 (0 saved) │ │ exec speed : 3143/sec │ total tmouts : 0 (0 saved) │
519├─ fuzzing strategy yields ├─ fuzzing strategy yields ────────────┴─────────────┬─ item geometry ───────┤ item geometry ───────┤
520│ bit flips : │ bit flips : 11/648, 4/638, 5/618 │ levels : 4 │ 4/638, 5/618 │ levels : │ bit flips : 11/648, 4/638, 5/618 │ levels : 4 │ │
521│ byte flips : │ byte flips : 0/81, 0/71, 0/52 │ pending : 199 │ 0/71, 0/52 │ pending : 199 │
522│ arithmetics : 11/4494, │ arithmetics : 11/4494, 0/1153, 0/0 │ pend fav : 35 │ 0/0 │ pend fav : 35 │
523│ known ints : 1/448, 0/1986, 0/2288 │ own finds : 207 │ known ints : │ known ints : 1/448, 0/1986, 0/2288 │ own finds : 207 │ 0/1986, 0/2288 │ own finds : 207 │
524│ dictionary : 0/0, │ dictionary : 0/0, 0/0, 0/0, 0/0 │ imported : 0 │ 0/0, 0/0 │ imported : 0 │
525│havoc/splice : 142/146k, 23/7616 │havoc/splice : 142/146k, 23/7616 │ stability : 100.00% │ stability : 100.00% │
526│py/custom/rq : unused, unused, │py/custom/rq : unused, unused, unused, unused ├───────────────────────┘ unused ├───────────────────────┘
527│ trim/eff : 57.02%/26, │ trim/eff : 57.02%/26, 0.00% │ [cpu000:100%] │ [cpu000:100%]
528└────────────────────────────────────────────────────┘^C └────────────────────────────────────────────────────┘^C
5290
530" \
531 "" \
532 "\
533─ process timing ────────────────────────────────────┬─ overall results ────┐
534│ run time : 0 days, 0 hrs, 0 min, 56 sec │ cycles done : 0 │
535│ last new find : 0 days, 0 hrs, 0 min, 1 sec │ corpus count : 208 │
536│last saved crash : none seen yet │saved crashes : 0 │
537│ last saved hang : none seen yet │ saved hangs : 0 │
538├─ cycle progress ─────────────────────┬─ map coverage┴──────────────────────┤
539│ now processing : 184.1 (88.5%) │ map density : 0.30% / 0.52% │
540│ runs timed out : 0 (0.00%) │ count coverage : 2.18 bits/tuple │
541├─ stage progress ─────────────────────┼─ findings in depth ─────────────────┤
542│ now trying : havoc │ favored items : 43 (20.67%) │
543│ stage execs : 11.2k/131k (8.51%) │ new edges on : 52 (25.00%) │
544│ total execs : 179k │ total crashes : 0 (0 saved) │
545│ exec speed : 3143/sec │ total tmouts : 0 (0 saved) │
546├─ fuzzing strategy yields ────────────┴─────────────┬─ item geometry ───────┤
547│ bit flips : 11/648, 4/638, 5/618 │ levels : 4 │
548│ byte flips : 0/81, 0/71, 0/52 │ pending : 199 │
549│ arithmetics : 11/4494, 0/1153, 0/0 │ pend fav : 35 │
550│ known ints : 1/448, 0/1986, 0/2288 │ own finds : 207 │
551│ dictionary : 0/0, 0/0, 0/0, 0/0 │ imported : 0 │
552│havoc/splice : 142/146k, 23/7616 │ stability : 100.00% │
553│py/custom/rq : unused, unused, unused, unused ├───────────────────────┘
554│ trim/eff : 57.02%/26, 0.00% │ [cpu000:100%]
555└────────────────────────────────────────────────────┘^C"
556
557# If field separator FS=' ' (default), fields are split only on
558# space or tab or linefeed, NOT other whitespace.
559testing 'awk does not split on CR (char 13)' \
560 "awk '{ \$1=\$0; print }'" \
561 'word1 word2 word3\r word2 word3\r\n' \
562 '' 'word1 word2 word3\r'
563
564testing "awk = has higher precedence than == (despite what gawk manpage claims)" \
565 "awk 'BEGIN { v=1; print 2==v; print 2==v=2; print v; print v=3==3; print v}'" \
566 '0\n1\n2\n1\n3\n' \
567 '' ''
568
569sq="'"
570testing 'awk gensub backslashes \' \
571 'awk '$sq'BEGIN { s="\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
572 's=\\
573\\|\\
574' '' ''
575testing 'awk gensub backslashes \\' \
576 'awk '$sq'BEGIN { s="\\\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
577 's=\\\\
578\\|\\
579' '' ''
580# gawk 5.1.1 handles trailing unpaired \ inconsistently.
581# If replace string is single \, it is used verbatim,
582# but if it is \\\ (three slashes), gawk uses "\<NUL>" (!!!), not "\\" as you would expect.
583testing 'awk gensub backslashes \\\' \
584 'awk '$sq'BEGIN { s="\\\\\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
585 's=\\\\\\
586\\\\|\\\\
587' '' ''
588testing 'awk gensub backslashes \\\\' \
589 'awk '$sq'BEGIN { s="\\\\\\\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
590 's=\\\\\\\\
591\\\\|\\\\
592' '' ''
593testing 'awk gensub backslashes \&' \
594 'awk '$sq'BEGIN { s="\\&"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
595 's=\\&
596&|&
597' '' ''
598testing 'awk gensub backslashes \0' \
599 'awk '$sq'BEGIN { s="\\0"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
600 's=\\0
601a|a
602' '' ''
603testing 'awk gensub backslashes \\0' \
604 'awk '$sq'BEGIN { s="\\\\0"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
605 's=\\\\0
606\\0|\\0
607' '' ''
608
609# The "b" in "abc" should not match <b* pattern.
610# Currently we use REG_STARTEND ("This flag is a BSD extension, not present in POSIX")
611# to implement the code to handle this correctly, but if your libc has no REG_STARTEND,
612# the alternative code mishandles this case.
613testing 'awk gsub erroneous word start match' \
614 "awk 'BEGIN { a=\"abc\"; gsub(/\<b*/,\"\",a); print a }'" \
615 'abc\n' \
616 '' ''
617
502exit $FAILCOUNT 618exit $FAILCOUNT