free: Update tests and fix for previous patch
The previous two patches updated free, but needed a tweak and the tests
also needed to be updated. I've hand-calculated the results using bc and
both the testsuite and bc results equal what free prints out.
References:
commit 9365be7633
procps-ng/procps#45
This commit is contained in:
parent
ff700abc72
commit
233b5228be
1
NEWS
1
NEWS
@ -1,6 +1,7 @@
|
|||||||
procps-ng-NEXT
|
procps-ng-NEXT
|
||||||
----------------
|
----------------
|
||||||
* doc: Document I idle state in ps.1 and top.1 Debian #886967
|
* doc: Document I idle state in ps.1 and top.1 Debian #886967
|
||||||
|
* free: fix some of the SI multiples issue #45
|
||||||
* kill: -l space between name parses correctly Debian #854407
|
* kill: -l space between name parses correctly Debian #854407
|
||||||
* library: dont use vm_min_free on non Linux Debian #831396
|
* library: dont use vm_min_free on non Linux Debian #831396
|
||||||
* library: dont use SIGPWR on FreeBSD Debian #832148
|
* library: dont use SIGPWR on FreeBSD Debian #832148
|
||||||
|
2
free.c
2
free.c
@ -133,7 +133,7 @@ static const char *scale_size(unsigned long size, int flags, struct commandline_
|
|||||||
if (args.exponent > 1) {
|
if (args.exponent > 1) {
|
||||||
/* In desired scale. */
|
/* In desired scale. */
|
||||||
snprintf(buf, sizeof(buf), "%ld",
|
snprintf(buf, sizeof(buf), "%ld",
|
||||||
(long int)((size / 1024) * base / power(base, args.exponent - 2))
|
(long int)((size * 1024) / power(base, args.exponent-1))
|
||||||
);
|
);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,12 @@ set swaptotal [ expr { $swaptotal_kb * 1024 } ]
|
|||||||
spawn $free -b
|
spawn $free -b
|
||||||
expect_pass "$test" "^${free_header}Mem:\\s+${memtotal}\\s+\\d+\\s+\\d+\\s+\\d+\\s+\\d+\\s+\\d+\\s*Swap:\\s+${swaptotal}\\s+\\d+\\s+\\d+\\s*"
|
expect_pass "$test" "^${free_header}Mem:\\s+${memtotal}\\s+\\d+\\s+\\d+\\s+\\d+\\s+\\d+\\s+\\d+\\s*Swap:\\s+${swaptotal}\\s+\\d+\\s+\\d+\\s*"
|
||||||
|
|
||||||
foreach {arg divisor } {-k 1 -m 1024 -g 1048576 --mega 1000 --giga 1000000 } {
|
foreach {arg divisor } {-k 1024 -m 1048576 -g 1073741824 --kilo 1000 --mega 1000000 --giga 1000000000 } {
|
||||||
set test "free with $arg argument"
|
set test "free with $arg argument"
|
||||||
set memtotal [ expr { $memtotal_kb / $divisor } ]
|
set memtest [ expr { $memtotal / $divisor } ]
|
||||||
set swaptotal [ expr { $swaptotal_kb / $divisor } ]
|
set swaptest [ expr { $swaptotal / $divisor } ]
|
||||||
spawn $free $arg
|
spawn $free $arg
|
||||||
expect_pass "$test" "^${free_header}Mem:\\s+$memtotal\\s+\\d+\\s+\\d+\\s+\\d+\\s+\\d+\\s+\\d+\\s*Swap:\\s+${swaptotal}\\s+\\d+\\s+\\d+\\s*"
|
expect_pass "$test" "^${free_header}Mem:\\s+$memtest\\s+\\d+\\s+\\d+\\s+\\d+\\s+\\d+\\s+\\d+\\s*Swap:\\s+${swaptest}\\s+\\d+\\s+\\d+\\s*"
|
||||||
}
|
}
|
||||||
|
|
||||||
#set test "free with human readable output"
|
#set test "free with human readable output"
|
||||||
|
Loading…
Reference in New Issue
Block a user