File: check-zzuf-m-md5

package info (click to toggle)
zzuf 0.15-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,280 kB
  • ctags: 916
  • sloc: ansic: 7,266; sh: 581; cpp: 352; makefile: 80
file content (36 lines) | stat: -rwxr-xr-x 992 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
#
#  check-zzuf-m-md5 - test "zzuf -m" flag (md5 checksums)
#
#  Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
#
#  This program is free software. It comes without any warranty, to
#  the extent permitted by applicable law. You can redistribute it
#  and/or modify it under the terms of the Do What the Fuck You Want
#  to Public License, Version 2, as published by the WTFPL Task Force.
#  See http://www.wtfpl.net/ for more details.
#

. "$(dirname "$0")/functions.inc"

checkmd5()
{
    CMD="$1"
    REFMD5="$2"
    printf " $(echo "$CMD .............................." | cut -b1-30) "
    MD5="$(eval "$CMD | $ZZUF -m -r0" 2>/dev/null | cut -f2 -d' ')"
    if [ "$MD5" != "$REFMD5" ]; then
        fail_test "$MD5 FAILED"
    else
        pass_test 'ok'
    fi
}

start_test "zzuf -m test"

checkmd5 "printf ''" d41d8cd98f00b204e9800998ecf8427e
checkmd5 echo 68b329da9893e34099c7d8ad5cb9c940
checkmd5 "printf 'hello world'" 5eb63bbbe01eeed093cb22bb8f5acdc3

stop_test