432
# was misinterpreted as (("str"++) i) instead of ("str" (++i))
433
# (and was executed: "str"++ is "0", thus concatenating "0" and "1"):
434
testing 'awk do not allow "str"++' \
435
'awk -v i=1 "BEGIN {print \"str\" ++i}"' \
440
# gawk compat: FS regex matches only non-empty separators:
441
# with -*, the splitting is NOT f o o b a r, but foo bar:
442
testing 'awk FS regex which can match empty string' \
443
"awk -F '-*' '{print \$1 \"-\" \$2 \"=\" \$3 \"*\" \$4}'" \
448
# last+1 field should be empty (had a bug where it wasn't)
449
testing 'awk $NF is empty' \
450
"awk -F '=+' '{print \$NF}'" \
455
testing "awk exit N propagates through END's exit" \
456
"awk 'BEGIN { exit 42 } END { exit }'; echo \$?" \
460
testing "awk print + redirect" \
461
"awk 'BEGIN { print \"STDERR %s\" >\"/dev/stderr\" }' 2>&1" \
465
testing "awk \"cmd\" | getline" \
466
"awk 'BEGIN { \"echo HELLO\" | getline; print }'" \
470
# printf %% should print one % (had a bug where it didn't)
471
testing 'awk printf %% prints one %' \
472
"awk 'BEGIN { printf \"%%\n\" }'" \
476
testing 'awk backslash+newline eaten with no trace' \
477
"awk 'BEGIN { printf \"Hello\\
482
testing 'awk assign while test' \
483
"awk '\$1==\$1=\"foo\" {print \$1}'" \
488
# User-supplied bug (SEGV) example, was causing use-after-realloc
489
testing 'awk assign while assign' \
490
"awk '\$5=\$\$5=\$0'; echo \$?" \
492
─ process timing ────────────────────────────────────┬─ ─ process timing ────────────────────────────────────┬─ overall results ────┐ results ────┐
493
│ 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 │
494
│ 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 │
495
│last saved crash : │last saved crash : none seen yet │saved crashes : 0 │ seen yet │saved crashes : 0 │
496
│ last saved hang │ last saved hang : none seen yet │ saved hangs : 0 │ none seen yet │ saved hangs : 0 │
497
├─ cycle progress ─────────────────────┬─ ├─ cycle progress ─────────────────────┬─ map coverage┴──────────────────────┤ coverage┴──────────────────────┤
498
│ 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% │
499
│ runs timed out │ runs timed out : 0 (0.00%) │ count coverage : 2.18 bits/tuple │ 0 (0.00%) │ count coverage : 2.18 bits/tuple │
500
├─ stage progress ─────────────────────┼─ ├─ stage progress ─────────────────────┼─ findings in depth ─────────────────┤ in depth ─────────────────┤
501
│ now trying : │ now trying : havoc │ favored items : 43 (20.67%) │ │ favored items : 43 (20.67%) │
502
│ 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%) │
503
│ total execs : │ total execs : 179k │ total crashes : 0 (0 saved) │ │ total crashes : 0 (0 saved) │ │ total execs : 179k │ total crashes : 0 (0 saved) │
504
│ 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) │
505
├─ fuzzing strategy yields ├─ fuzzing strategy yields ────────────┴─────────────┬─ item geometry ───────┤ item geometry ───────┤
506
│ 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 │ │
507
│ byte flips : │ byte flips : 0/81, 0/71, 0/52 │ pending : 199 │ 0/71, 0/52 │ pending : 199 │
508
│ arithmetics : 11/4494, │ arithmetics : 11/4494, 0/1153, 0/0 │ pend fav : 35 │ 0/0 │ pend fav : 35 │
509
│ 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 │
510
│ dictionary : 0/0, │ dictionary : 0/0, 0/0, 0/0, 0/0 │ imported : 0 │ 0/0, 0/0 │ imported : 0 │
511
│havoc/splice : 142/146k, 23/7616 │havoc/splice : 142/146k, 23/7616 │ stability : 100.00% │ stability : 100.00% │
512
│py/custom/rq : unused, unused, │py/custom/rq : unused, unused, unused, unused ├───────────────────────┘ unused ├───────────────────────┘
513
│ trim/eff : 57.02%/26, │ trim/eff : 57.02%/26, 0.00% │ [cpu000:100%] │ [cpu000:100%]
514
└────────────────────────────────────────────────────┘^C └────────────────────────────────────────────────────┘^C
519
─ process timing ────────────────────────────────────┬─ overall results ────┐
520
│ run time : 0 days, 0 hrs, 0 min, 56 sec │ cycles done : 0 │
521
│ last new find : 0 days, 0 hrs, 0 min, 1 sec │ corpus count : 208 │
522
│last saved crash : none seen yet │saved crashes : 0 │
523
│ last saved hang : none seen yet │ saved hangs : 0 │
524
├─ cycle progress ─────────────────────┬─ map coverage┴──────────────────────┤
525
│ now processing : 184.1 (88.5%) │ map density : 0.30% / 0.52% │
526
│ runs timed out : 0 (0.00%) │ count coverage : 2.18 bits/tuple │
527
├─ stage progress ─────────────────────┼─ findings in depth ─────────────────┤
528
│ now trying : havoc │ favored items : 43 (20.67%) │
529
│ stage execs : 11.2k/131k (8.51%) │ new edges on : 52 (25.00%) │
530
│ total execs : 179k │ total crashes : 0 (0 saved) │
531
│ exec speed : 3143/sec │ total tmouts : 0 (0 saved) │
532
├─ fuzzing strategy yields ────────────┴─────────────┬─ item geometry ───────┤
533
│ bit flips : 11/648, 4/638, 5/618 │ levels : 4 │
534
│ byte flips : 0/81, 0/71, 0/52 │ pending : 199 │
535
│ arithmetics : 11/4494, 0/1153, 0/0 │ pend fav : 35 │
536
│ known ints : 1/448, 0/1986, 0/2288 │ own finds : 207 │
537
│ dictionary : 0/0, 0/0, 0/0, 0/0 │ imported : 0 │
538
│havoc/splice : 142/146k, 23/7616 │ stability : 100.00% │
539
│py/custom/rq : unused, unused, unused, unused ├───────────────────────┘
540
│ trim/eff : 57.02%/26, 0.00% │ [cpu000:100%]
541
└────────────────────────────────────────────────────┘^C"
543
# If field separator FS=' ' (default), fields are split only on
544
# space or tab or linefeed, NOT other whitespace.
545
testing 'awk does not split on CR (char 13)' \
546
"awk '{ \$1=\$0; print }'" \
547
'word1 word2 word3\r word2 word3\r\n' \
548
'' 'word1 word2 word3\r'
550
testing "awk = has higher precedence than == (despite what gawk manpage claims)" \
551
"awk 'BEGIN { v=1; print 2==v; print 2==v=2; print v; print v=3==3; print v}'" \
556
testing 'awk gensub backslashes \' \
557
'awk '$sq'BEGIN { s="\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
561
testing 'awk gensub backslashes \\' \
562
'awk '$sq'BEGIN { s="\\\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
566
# gawk 5.1.1 handles trailing unpaired \ inconsistently.
567
# If replace string is single \, it is used verbatim,
568
# but if it is \\\ (three slashes), gawk uses "\<NUL>" (!!!), not "\\" as you would expect.
569
testing 'awk gensub backslashes \\\' \
570
'awk '$sq'BEGIN { s="\\\\\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
574
testing 'awk gensub backslashes \\\\' \
575
'awk '$sq'BEGIN { s="\\\\\\\\"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
579
testing 'awk gensub backslashes \&' \
580
'awk '$sq'BEGIN { s="\\&"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
584
testing 'awk gensub backslashes \0' \
585
'awk '$sq'BEGIN { s="\\0"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
589
testing 'awk gensub backslashes \\0' \
590
'awk '$sq'BEGIN { s="\\\\0"; print "s=" s; print gensub("a", s, "g", "a|a") }'$sq \
595
# The "b" in "abc" should not match <b* pattern.
596
# Currently we use REG_STARTEND ("This flag is a BSD extension, not present in POSIX")
597
# to implement the code to handle this correctly, but if your libc has no REG_STARTEND,
598
# the alternative code mishandles this case.
599
testing 'awk gsub erroneous word start match' \
600
"awk 'BEGIN { a=\"abc\"; gsub(/\<b*/,\"\",a); print a }'" \