# fribidi(1) — GNU FriBidi 1.0.14, the Unicode Bidirectional Algorithm (UAX #9). # # The first half of this suite is UPSTREAM'S OWN CONFORMANCE TEST, run on target # rather than re-invented: test/test_*.input and test/test_*.reference ship in the # tarball, meson registers them as the project's six `meson test` cases, and # upstream's test-runner.py does nothing but diff `fribidi --test --charset CS # INPUT` against the reference file. There is no python on this image, but there # does not need to be — that comparison is one `cmp`. So the six vectors ride in # as data/fribidi-*.input|.reference and are asserted BYTE-EXACT here, which is a # stronger statement than any hand-written case: 118 lines of bidi text across # four character sets, covering implicit reordering, explicit embedding codes, # LRI/RLI/FSI isolates, Hebrew in ISO8859-8, Persian with Arabic shaping, and NSM # reordering. `--test` pins its own width (--clean --nobreak --showinput # --reordernsm --width 80), so the output is immune to COLUMNS. # # The second half drives the CLI directly for the things a vector file cannot # state: the auxiliary outputs (--basedir/--ltov/--vtol/--levels), padding, the # exit-status conventions, and that the -dev/-staticdev halves of the port # actually landed. # # CapRTL is upstream's test charset — ASCII where capitals are strong RTL — so # every reordering assertion below is plain ASCII and reads as its own proof. # Expected values are byte-identical to a native x86_64 build of the identical # 1.0.14 source. . "$BST_LIB" require fribidi fribidi/present # --- upstream's six conformance vectors, byte-exact --------------------------- tmp=${TMPDIR:-/tmp}/bst-fribidi.$$ for pair in \ CapRTL:CapRTL_explicit \ CapRTL:CapRTL_implicit \ CapRTL:CapRTL_isolate \ ISO8859-8:ISO8859-8_hebrew \ UTF-8:UTF-8_persian \ UTF-8:UTF-8_reordernsm do cs=${pair%%:*}; name=${pair#*:} id=fribidi/vec-$(printf '%s' "$name" | tr 'A-Z_' 'a-z-') in=$BST_DATA/fribidi-$name.input ref=$BST_DATA/fribidi-$name.reference if [ ! -f "$in" ] || [ ! -f "$ref" ]; then bst_notok "$id" "vector payload missing: $in" continue fi out=$(fribidi --test --charset "$cs" "$in" 2>&1 > "$tmp"); rc=$? if [ "$rc" -ne 0 ]; then bst_notok "$id" "rc=$rc $(_bst_1line "$out")" elif cmp -s "$tmp" "$ref"; then bst_ok "$id" else bst_notok "$id" "output differs from upstream reference ($(wc -c < "$tmp") vs $(wc -c < "$ref") bytes)" fi done rm -f "$tmp" # --- the reordering itself, in the shell -------------------------------------- # Upstream's canonical example: the capitals are one RTL run inside an LTR line. check_eq fribidi/caprtl-implicit \ 'car is RAC EHT in arabic' \ "$(printf 'car is THE CAR in arabic\n' | fribidi --charset CapRTL --nopad)" # Base direction is auto-detected from the first strong character, and forcing it # changes the answer — three separate paragraph-level decisions on one input. check_out fribidi/basedir-auto-rtl 'Base direction: R' \ sh -c "printf 'CAR IS the car\n' | fribidi --charset CapRTL --nopad --basedir --novisual" check_eq fribidi/force-ltr 'SI RAC the car' \ "$(printf 'CAR IS the car\n' | fribidi --charset CapRTL --nopad --ltr)" check_eq fribidi/force-rtl 'RAC EHT car is' \ "$(printf 'car is THE CAR\n' | fribidi --charset CapRTL --nopad --rtl)" # --- the auxiliary outputs ---------------------------------------------------- # Embedding levels are the algorithm's actual intermediate result: the seven # capitals of "THE CAR" sit at level 1 inside a level-0 paragraph. check_eq fribidi/levels \ '0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ' \ "$(printf 'car is THE CAR in arabic\n' | fribidi --charset CapRTL --nopad --levels --novisual)" check_eq fribidi/ltov '2 1 0 ' \ "$(printf 'CAR\n' | fribidi --charset CapRTL --nopad --ltov --novisual)" check_eq fribidi/vtol '2 1 0 ' \ "$(printf 'CAR\n' | fribidi --charset CapRTL --nopad --vtol --novisual)" # --- padding, delimiters, and the input echo ---------------------------------- # Without --nopad an RTL line is right-justified into the screen width. check_eq fribidi/pad-width ' RAC' \ "$(printf 'CAR\n' | fribidi --charset CapRTL --width 10)" check_eq fribidi/bol-eol '' \ "$(printf 'CAR\n' | fribidi --charset CapRTL --nopad -B '<' -E '>')" check_out fribidi/showinput '=> RAC' \ sh -c "printf 'CAR\n' | fribidi --charset CapRTL --nopad --width 80 --showinput" # --clean strips the explicit format codes (here CapRTL's _L LRE and _o PDF) # from the visual string instead of leaving them to render as literal text. check_eq fribidi/clean 'this is JUST' \ "$(printf 'this is _LJUST_o\n' | fribidi --charset CapRTL --nopad --clean)" # --- character sets ----------------------------------------------------------- # Default charset is UTF-8 and needs no flag: a Hebrew word followed by an ASCII # one, in an RTL paragraph, comes back with the Hebrew reversed and the ASCII run # left intact. Written with octal escapes so this file stays 7-bit. heb_in=$(printf '\327\251\327\234\327\225\327\235 abc') heb_want=$(printf 'abc \327\235\327\225\327\234\327\251') check_eq fribidi/utf8-hebrew "$heb_want" \ "$(printf '%s\n' "$heb_in" | fribidi --nopad)" check_out fribidi/charset-list '* CapRTL : CapRTL (Test)' fribidi --help check_out fribidi/charsetdesc 'CapRTL is a character set for testing' \ fribidi --charsetdesc CapRTL # --- version and the exit-status conventions ---------------------------------- check_out fribidi/version 'fribidi (GNU FriBidi) 1.0.14' fribidi --version # The UCD revision the shipped tables were generated from, by gen.tab's NATIVE # helper programs at build time — so this line is also the evidence that the # cross build ran those generators rather than shipping someone else's tables. check_out fribidi/ucd-version 'Unicode Character Database version 10.0.0' \ fribidi --version check_out fribidi/help 'A command line interface for the GNU FriBidi library.' \ fribidi --help check_rc fribidi/rc-ok 0 sh -c "printf 'CAR\n' | fribidi --charset CapRTL" check_rc fribidi/rc-missing-file 1 fribidi /no/such/file # Two upstream warts, pinned so a fix is noticed rather than silently changing # behaviour: an unrecognised option and an unrecognised charset both exit 255 # (exit(-1)), not 1 or 2. check_rc fribidi/rc-bad-option 255 sh -c "fribidi --no-such-option /dev/null | grep -q ." check_out fribidi/pkgconfig-version 'Version: 1.0.14' cat /usr/lib/pkgconfig/fribidi.pc check_out fribidi/pkgconfig-libs '-lfribidi' cat /usr/lib/pkgconfig/fribidi.pc