File: 05-sort-by-size.test

package info (click to toggle)
nginx 1.18.0-6.1%2Bdeb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 19,344 kB
  • sloc: ansic: 250,653; perl: 7,548; sh: 1,408; ruby: 879; python: 358; makefile: 338; awk: 36; cpp: 18
file content (36 lines) | stat: -rw-r--r-- 820 bytes parent folder | download | duplicates (4)
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/bash
cat <<---
This test validates that the sorting by file size works.
--
use pup
nginx_start

# Ascending sort.
previous=''
while read -r size ; do
	if [[ ${size} = - ]] ; then
		continue
	fi
	if [[ -z ${previous} ]] ; then
		previous=${size}
		continue
	fi
	[[ ${previous} -le ${size} ]] || fail \
		'Size %d should be smaller than %d\n' "${previous}" "${size}"
done < <( fetch '/?C=S&O=A' \
	    | pup -p body table tbody 'td:nth-child(2)' text{} )

# Descending sort.
previous=''
while read -r size ; do
	if [[ ${size} = - ]] ; then
		continue
	fi
	if [[ -z ${previous} ]] ; then
		previous=${size}
		continue
	fi
	[[ ${previous} -ge ${size} ]] || fail \
		'Size %d should be greater than %d\n' "${previous}" "${size}"
done < <( fetch '/?C=S&O=D' \
	    | pup -p body table tbody 'td:nth-child(2)' text{} )