aboutsummaryrefslogtreecommitdiff
path: root/core/test
AgeCommit message (Collapse)AuthorFilesLines
2017-08-24core/test/run-msg: don't depend on unittest mem layoutStewart Smith1-1/+1
In the world of unit tests all "RAM" is valid Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-08-24core/test/run-device: fix memory leak on exitStewart Smith1-0/+1
Shuts LeakSanitizer up Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-08-24test/mem_region: fix incorrect ibm,os-reserve region lengthStewart Smith2-4/+4
We were reserving all of memory up to the heap, which is fine *unless* the system libc chooses to allocate something in that block of memory that we use, which means we have overlapping regions and general pain. This should fix failing unit tests on some systems (e.g. Debian) Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-08-23Fix mem leak in core/test/run-time-utilsStewart Smith1-0/+3
Fixes the following LeakSanitizer errors: ================================================================= ==32426==ERROR: LeakSanitizer: detected memory leaks Direct leak of 56 byte(s) in 1 object(s) allocated from: #0 0x7fd94a1fa850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x4014d4 in main core/test/run-time-utils.c:30 #2 0x7fd94904c509 in __libc_start_main (/lib64/libc.so.6+0x20509) Direct leak of 8 byte(s) in 1 object(s) allocated from: #0 0x7fd94a1fa850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x4014f0 in main core/test/run-time-utils.c:32 #2 0x7fd94904c509 in __libc_start_main (/lib64/libc.so.6+0x20509) Direct leak of 4 byte(s) in 1 object(s) allocated from: #0 0x7fd94a1fa850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x4014e2 in main core/test/run-time-utils.c:31 #2 0x7fd94904c509 in __libc_start_main (/lib64/libc.so.6+0x20509) Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-07-19attrconst for testsStewart Smith3-3/+3
Fixes build warnings when running with higher optimization than -O0 Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-06-27dt: Add phandle fixup helpersMadhavan Srinivasan1-2/+33
When there is a new device tree that needs to be added to the main dt of the opal (ex, IMC catalog dtb loaded from pnor partition), we need to check for the phandle values in the new incoming device tree before attaching it. Reason is that, incoming device tree could already have phandle values initialized for its nodes. Now, if we attach this new device tree to the main opal DT, we could potentially hit phandle duplicate error (since the phandles value usually start with 1). To avoid this, a new helper function dt_adjust_subtree_phandle() is added to scan the incoming device tree and update node "phandle" accordingly based on the opal "last_phandle" value. Add to this, helper function also supports updates of "properties" with in a node which may refer the "phandle" value in the incoming device tree. Helper function will also fix the "properties" field accordingly. Acked-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-06-06Convert important polling loops to spin at lowest SMT priorityNicholas Piggin1-0/+2
The pattern of calling cpu_relax() inside a polling loop does not suit the powerpc SMT priority instructions. Prefrred is to set a low priority then spin until break condition is reached, then restore priority. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> [stewart@linux.vnet.ibm.com: fixup lpc-uart wait_tx_room() and unit test] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-05-26mem_region: rename HW_RESERVE to FW_RESERVEOliver O'Halloran2-3/+3
Currently all existing reservations are made by hostboot itself or on behalf of some other part of system firmware (e.g. the OCCs). We want to add a "true" hardware reservation type that should not be touched by the host OS. To prepare for that this patch renames the existing reservation type to refect it's actual usage. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-05-16core/test: Test pre-init memory reservationsOliver O'Halloran1-6/+9
Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-04-07device: add dt_find_by_name_addrOliver O'Halloran1-0/+1
Adds two helper functions that allow device nodes to be found via their name and unit address. One will take an integer address and format it to a hex string while the other looks up the unit based a user supplied string. This is handy in a few places inside the HDAT parser. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-03-07core/test: use strcmp for console testsOliver O'Halloran2-6/+6
The console logging tests use a memcmp and strlen() with string literal arguments. Unfortunately the strings were updated at some point and not kept in sync. strcmp() should be fine here so use that instead. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-03-07core/test/run-trace: Reduce number of samples when running under valgrindStewart Smith1-1/+3
This reduces 'make check' run time by ~10 seconds on my laptop, and just the run-trace test itself takes 15 seconds less (under valgrind). Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-03-07device: implement dt_translate_address() properlyOliver O'Halloran1-1/+46
Currently this is implemented by calling dt_get_address() which only works when a device is a child of the root node. This patch implements the functionality to work with nested nodes when all parent nodes have an appropriate "ranges" property. This implementation only works for up to 64 bit addresses. Properly supporting larger addressing schemes is a fair amount of (probably pointless) work, so I'm leaving supporting that until we have an actual a need for it. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Tested-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-02-23nvram-format: Fix endian issuesStewart Smith1-3/+3
NVRAM formats are always BE, so let's use the sparse annotation to catch any issues (and correct said issues). On LE platforms, the test was erroneously passing as with building the nvram-format code on LE we were produces an incorrect NVRAM image. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-01-05core/test/run-buddy: add one more test to get to 100% lines coveredStewart Smith1-1/+2
We're now only missing some assert() branches in buddy testing. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-01-05buddy: Add a simple generic buddy allocatorBenjamin Herrenschmidt2-1/+84
It operates on bits representing whatever objects the caller wants it to represent, it's not per-se a memory allocator (it's meant to be used among others by XIVE for VP allocations). As such it cannot keep linked lists of free objects, so don't expect stellar perfs. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> [stewart@linux.vnet.ibm.com: add (C) header, fix gcc4.8 build error] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-01-04Add bitmap testStewart Smith2-1/+82
The worst test suite ever Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-25core/flash-subpartition: compute partition size from subpartition structStewart Smith1-1/+5
From the subpartition structure, we have the ability to compute the full partition size. Do that. This lets us only read the amount of a subpartition that is valid and needed to be read, rather than having to read the entire thing. We continue the current behaviour of loading flash partitions though. Based-on-patch-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-25core/flash: Move subpartition locating logic out into own file, add testsStewart Smith2-0/+56
A unit test for parsing sub-partition info is useful for a number of reasons, one of which showed its head during development of secure/trusted boot. This patch just moves things around, there's no functional changes. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-17console-log: print full remaining timebase in skiboot logStewart Smith3-9/+9
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-14nvram: force re-verification after writingOliver O'Halloran1-0/+5
The running OS is free to re-write the contents of NVRAM. The skiboot NVRAM parser relies on the NVRAM contents being valid so we need to force the NVRAM contents to be revalidated after the host OS has written to it. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-11core/pel: Validate 'system-id' DT property before usingVasant Hegde1-5/+19
Platforms like mambo doesn't populate 'system-id' DT property. Validate these properties before using. Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> [stewart@linux.vnet.ibm.com, memset(0) for not found dt props, fix unit test] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-09-02consolidate gcov flags into HOSTGCOVFLAGS for host binariesStewart Smith1-2/+2
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-30core/test: add tests for nvram_query()Oliver O'Halloran1-0/+46
Adds some basic functionality tests for nvram_query() to the core test suite. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-30core/test: add test for nul check in nvram_format()Oliver O'Halloran1-0/+6
Adds a test for nvram_check() that the ibm,skiboot nvram partition is correctly terminated. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-24Make console-log time more readable: seconds rather than timebaseBalbir Singh3-10/+16
I've tried to align it with what the kernel prints today The existing logs show: [20287269125,5] PSI[0x000]: Found PSI bridge [working=1, active=0] [890425679,5] BT: Interface initialized, IO 0x00e4 [1249199642,4] SLW: HB-provided idle states property found [1249344409,5] NVRAM: Size is 576 KB [1484422964,3] NVRAM: Layout appears sane The mftb() output is not very meaningful, the changed output shows: [ 38.315784591,5] CENTAUR: FSI host: 0x0 cMFSI0 port 2 [ 38.315922971,5] PSI[0x000]: Found PSI bridge [working=1, active=0] [ 1.448765255,5] BT: Interface initialized, IO 0x00e4 [ 2.398136129,5] NVRAM: Size is 576 KB [ 3.145017865,3] NVRAM: Layout appears sane For the output sample, I've taken bits where one can see the time move back w.r.t. previous log, but that was always the case. I don't think that is worth fixing here Adds an additional divide and modulo for every log printed. I've also fixed the test cases that run as a part of make check Signed-off-by: Balbir Singh <bsingharora@gmail.com> [stewart@linux.vnet.ibm.com: fix up tb in console tests] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-18check: Fix bugs in mem region testsBenjamin Herrenschmidt2-2/+0
We shouldn't delete the list element after list_pop, it's already been deleted. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-18Build host programs (and checks) with debug enabledBenjamin Herrenschmidt3-1/+4
This enables memory poisoning in allocations and list checking among other things. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-17Use additional checks in skiboot for pointersBalbir Singh1-0/+3
The checks validate pointers sent in using opal_addr_valid() in opal_call API's provided via the console, cpu, fdt, flash, i2c, interrupts, nvram, opal-msg, opal, opal-pci, xscom and cec modules Signed-off-by: Balbir Singh <bsingharora@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-12Add infrastructure for pointer validation.Balbir Singh2-0/+52
If the kernel called an OPAL API with vmalloc'd address or any other address range in real mode, we would hit a problem with aliasing. Since the top 4 bits are ignored in real mode, pointers from 0xc.. and 0xd.. (and other ranges) could collide and lead to hard to solve bugs. This patch adds the infrastructure for pointer validation and a simple test case for testing the API Signed-off-by: Balbir Singh <bsingharora@gmail.com> [stewart@linux.vnet.ibm.com: move function to opal-internal.h rather than opal-api.h] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-12make check: make test runs less noisyStewart Smith1-4/+4
Run a small wrapper around some unit tests with the QTEST makefile macro (QTEST=Quiet TEST). Also, wrap boot tests in mambo and qemu to be quiet by default. Both ./test/run.sh and the modified mambo/qemu test runner scripts output full stdout and stderr in the event of error. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-06Timebase quirk for slow simulators like AWAN and SIMICSBenjamin Herrenschmidt2-0/+4
This will internally pretend the timebase is running 1000 times slower, which reduces some otherwise really terrible delays in some simulators. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Michael Neuling <mikey@neuling.org> [stewart@linux.vnet.ibm.com: move cfam_chipid cleanup into own patch] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-03-30*/test/*: Added '<subdir>-check' make targetsOliver O'Halloran1-5/+8
Currently these exist for some parts of the source tree, but not all of it. They're nice if you are only modifing code in a one part of the tree as the full test suite can be a little slow. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-01-21Merge branch 'stable'Stewart Smith1-0/+71
Merge device tree sorting
2016-01-21DT sorting testOliver O'Halloran1-0/+71
Moved the dt_dump() into test/dt_common.c so that it can be shared between hdata/test/hdata_to_dt.c and core/test/run-device.c run-device.c contains two tests, one basic sorting test and a generate-and-sort test. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> [stewart@linux.vnet.ibm.com: remove trailing whitespace] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-01-21Enable -Werror for -WformatStewart Smith1-1/+1
commit 56bc1890b229072513788992d1d29b6f173c13de upstream We create our own inttypes.h to get the correct printf formatting for 64bit numbers. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-11-16Enable -Werror for -WformatStewart Smith1-1/+1
We create our own inttypes.h to get the correct printf formatting for 64bit numbers. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-11-16assert cpu < CPUS in core/test/run-trace.cStewart Smith1-2/+7
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-10-08Add unit test for timebase functionsStewart Smith2-0/+57
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-22Ensure reserved memory ranges are exposed correctly to host (fix corrupted ↵Stewart Smith2-2/+2
SLW image) Memory regions in skiboot have an interesting life cycle. First, we get a bunch from the initial device tree or hdat specifying some existing reserved ranges (as well as adding some of our own if they're missing) but we also get ranges for the entirety of RAM. The idea is that we can do node local allocations for per node resources (which we do) and then, just prior to booting linux, we copy the reserved memory regions to expose to linux along with a set of reserver regions to cover the node local allocations. The problem was that mem_range_is_reserved() was wanting subtle different semantics for memory region type than region_is_reserved() provided. That is, we were overriding the meaning of REGION_SKIBOOT_HEAP to mean both "this is reserved by skiboot" *and* "this is a memory region that covers all of memory and will be shrunk to cover just the memory we have allocated for it just before we boot the payload (linux)". So what would happen is we would ask "hey, is the memory holding the SLW image reserved?" and we'd get the answer of "yes" but referring to the memory region that covers the entirety of memory in a NUMA node, *not* meaning our intent of "this will be reserved when we start linux". To fix this, introduce a new memory region type REGION_MEMORY. This has the semantics of a memory region that covers a block of memory that we can allocate from (using local_alloc) and that the part that was allocated will be passed to linux as reserved, but that the entire range will not be reserved. So our new semantics are: - region_is_reservable() is true if the region *MAY* be reserved (i.e. is the regions that cover the whole of memory OR is explicitly reserved) - region_is_reserved() is true if the region *WILL* be reserved (i.e. is explicitly reserved) This way we check that the SLW image is explicitly reserved and if it isn't, we reserve it. Fixes: 58033e44 Acked-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-11slw/timer: SBE based timer supportBenjamin Herrenschmidt1-0/+6
Recent HostBoot & SBE firmware provide a HW timer facility that can be used to implement OPAL timers and thus limit the reliance on the Linux heartbeat. This implements support for it. The side effect is that i2c from Centaurs is now usable. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> [stewart@linux.vnet.ibm.com: fix run-timer unit test] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-11timer: Pass current timer to timer callbacksBenjamin Herrenschmidt1-1/+2
The caller usually has it and it avoids additional mftb() which can be expensive. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> [stewart@linux.vnet.ibm.com: fix run-timer unit test] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-09Fix harmless free() after realloc() in test-malloc.cStewart Smith1-2/+2
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-08trivial run-malloc test fixup that was fooling coverityStewart Smith1-1/+1
although we assert that p2==p, coverity doesn't pick this up, so we get a false positive of a double free. This is trivial to fix just by modifying our test case. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-17core/mem_region: Add mem_range_is_reserved()Jeremy Kerr2-0/+217
This change adds a function to check whether a range of memory is covered by one or more reservations. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-31fix run-pel.c build after error log entry changesStewart Smith1-1/+1
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-02Add mem_dump_free() call to mem_region unit testStewart Smith1-0/+2
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-24add test for nvram free space partition nameStewart Smith1-6/+3
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-24Expand nvram-format unit test to cover all error pathsStewart Smith1-2/+85
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-24Move NVRAM format/check code out into separate file to unit testStewart Smith2-0/+32
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>