1 | # Commands covered: Rappture::sysinfo |
---|
2 | # |
---|
3 | # This file contains a collection of tests for one of the Rappture Tcl |
---|
4 | # commands. Sourcing this file into Tcl runs the tests and |
---|
5 | # generates output for errors. No output means no errors were found. |
---|
6 | # |
---|
7 | # ====================================================================== |
---|
8 | # AUTHOR: Michael McLennan, Purdue University |
---|
9 | # Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
10 | # |
---|
11 | # See the file "license.terms" for information on usage and redistribution |
---|
12 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
13 | |
---|
14 | |
---|
15 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
16 | package require tcltest |
---|
17 | package require Rappture |
---|
18 | namespace import -force ::tcltest::* |
---|
19 | } |
---|
20 | |
---|
21 | #---------------------------------------------------------- |
---|
22 | # Rappture::sysinfo ?<key> <key> ...? |
---|
23 | #---------------------------------------------------------- |
---|
24 | test sysinfo-1 {query all system info} { |
---|
25 | set rval "" |
---|
26 | foreach {key val} [Rappture::sysinfo] { |
---|
27 | lappend rval $key |
---|
28 | } |
---|
29 | } {} |
---|
30 | |
---|
31 | test sysinfo-2 {query just a few parameters} { |
---|
32 | set info [Rappture::sysinfo uptime freeram totalram] |
---|
33 | regexp {^[0-9]+ +[0-9]+ +[0-9]+$} $info |
---|
34 | } {1} |
---|
35 | |
---|
36 | test sysinfo-3 {if a key name is not recognized, we get an error} { |
---|
37 | list [catch {Rappture::sysinfo uptime foo} msg] $msg |
---|
38 | } {1 {bad parameter "foo": should be one of freeram, freeswap, load1, load5, load15, procs, totalram, totalswap, uptime}} |
---|
39 | |
---|
40 | ::tcltest::cleanupTests |
---|
41 | return |
---|