9 Commits

Author SHA1 Message Date
Jenkins
2d02d29e27 Merge "Add vercmp function" 2016-01-29 05:21:09 +00:00
Swapnil Kulkarni (coolsvap)
7f0be4fc5f Updated Typos in devstack
(1/5) Updated HACKING.rst for typos
(2/5) Updated typos in lib/dlm
(3/5) Updated typos in lib/ironic
(4/5) Updated typos in unittest.sh
(5/5) Updated typos in test_meta_config.sh

Change-Id: I7aafa3af69df9dc6a5923a8557f380d48b73433a
2015-11-20 11:17:19 +05:30
Ian Wienand
2ba36cda79 Add vercmp function
The existing vercmp_numbers function only handles, as the name says,
numbers.  I noticed that "sort" has had a version sort for a long time
[1] and, rather than re-implement it badly, use this as a version of
vercmp that works a bit more naturally.

This is intended to be used in an "if" statement as in

  prog_ver=$(prog_ver --version | grep ...)
  if vercmp $prog_ver "<" 2.0; then
     ...
  fi

A test-case is added to test the basic features and some edge-cases.

[1] http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=4c9fae4e97d95a9f89d1399a8aeb03051f0fec96

Change-Id: Ie55283acdc40a095b80b2631a55310072883ad0d
2015-11-19 09:37:33 +11:00
Ian Wienand
ca7e4f285c Fix error detection & exit in report_results
We wish to fail if we have >0 zero errors, not >1 errors (i.e. exactly
one error did not trigger a failure!)

This change also brings consistency to the pass & failure paths by
ensuring report_results exits in both cases, since report_results is
supposed to be the last thing run in a test file.

Change-Id: Id4721dffe13721e6c3cd71bca40c3395627e98bf
2015-11-16 15:47:51 +11:00
Ian Wienand
ada886dd43 Don't mix declaration and set of locals
Ia0957b47187c3dcadd46154b17022c4213781112 proposes to have bashate
find instances of setting a local value.  The issue is that "local"
always returns 0, thus hiding any failure in the commands running to
set the variable.

This is an automated replacement of such instances

Depends-On: I676c805e8f0401f75cc5367eee83b3d880cdef81
Change-Id: I9c8912a8fd596535589b207d7fc553b9d951d3fe
2015-10-07 17:03:32 +11:00
Ian Wienand
b997db602e Cleanup of ini test-case
Various cleanup to this file.

Firstly create a temporary space to test, rather than working in the
source directory.

We have "assert_equal" which simplifies a lot.  Add "assert_empty"
that is used in a couple of tests too.  Remove a couple of duplicate
tests.

Change-Id: I7fd476ed63026e67d66a8ac2891b2e4a6687d09c
2015-07-23 06:46:24 +10:00
Ian Wienand
165afa2377 Fix msg argument to assert_equal
I noticed this was taking an argument but not dealing with it.  In
general the functions were undocumented, so I added some terse usage.

Also, the intent of the test-case was to expand the values before
using them as the message; make sure this happens by using a temp
variable.

Change-Id: Ib317ad1e9dd2a5d2232b9c64541fe4a601a2b8da
2015-05-25 11:29:48 +10:00
Ian Wienand
1cb809d8ef Add "passed" and "failed" functions
Add two generic "passed" and "failed" functions to the unittest
helper.  Also keep a count of passed and failed tests.  Later changes
will use these functions to ensure they exit with a correct return
code.

Change-Id: I8574dcb1447b04fcda3d72df0bf8605cf7488d3c
2015-04-17 13:23:20 +10:00
Sean Dague
537532931d Make changes such that -o nounset runs
This makes a bunch of variable cleanups that will let -o nounset
function, for the time being we hide nounset behind another setting
variable so that it's not on by default.

Because this is bash, and things are only executed on demand, this
probably only works in the config it was run in. Expect cleaning up
all the paths to be something that takes quite a while.

This also includes a new set of unit tests around the trueorfalse
function, because my change in how it worked, didn't. Tests are good
m'kay.

Change-Id: I71a896623ea9e1f042a73dc0678ce85acf0dc87d
2015-01-15 13:06:14 -05:00