diff options
author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-06-24 17:02:50 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-06-24 17:02:50 +1000 |
commit | e3e38fcc77e49378db230f06b5f38e3814229aae (patch) | |
tree | f8f807f23a40801b9ae46cb59569cd3b3f737679 /core/test | |
parent | e5b053749e75e959aa5cafc875327b66f571e73a (diff) | |
download | blackbird-skiboot-e3e38fcc77e49378db230f06b5f38e3814229aae.tar.gz blackbird-skiboot-e3e38fcc77e49378db230f06b5f38e3814229aae.zip |
Move NVRAM format/check code out into separate file to unit test
We (slightly) change the internal API so that we operate on parameters
rather than globals, this means it's easier to unit test too.
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/test')
-rw-r--r-- | core/test/Makefile.check | 1 | ||||
-rw-r--r-- | core/test/run-nvram-format.c | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/core/test/Makefile.check b/core/test/Makefile.check index 56ce61da..dfe73605 100644 --- a/core/test/Makefile.check +++ b/core/test/Makefile.check @@ -8,6 +8,7 @@ CORE_TEST := core/test/run-device \ core/test/run-mem_region_release_unused \ core/test/run-mem_region_release_unused_noalloc \ core/test/run-mem_region_reservations \ + core/test/run-nvram-format \ core/test/run-trace core/test/run-msg \ core/test/run-pel \ core/test/run-pool \ diff --git a/core/test/run-nvram-format.c b/core/test/run-nvram-format.c new file mode 100644 index 00000000..7fb4217e --- /dev/null +++ b/core/test/run-nvram-format.c @@ -0,0 +1,31 @@ +/* Copyright 2013-2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdlib.h> + +#include "../nvram-format.c" + +int main(void) +{ + char *nvram_image = malloc(0x100000); + + nvram_format(nvram_image, 0x100000); + + assert(nvram_check(nvram_image, 0x100000) == 0); + + free(nvram_image); + return 0; +} |