Revert "[zircon][utest][pager] Exclude root-resource tests at runtime, not compile"
This reverts commit fd4a750800aeabfe01beb0062a1eee7c873c3608.
Reason for revert: Landed accidentally via topic CQ snafu!
Original change's description:
> [zircon][utest][pager] Exclude root-resource tests at runtime, not compile
>
> Rather than using #ifdef BUILD_COMBINED_TESTS to decide whether the
> root resource handle will be available for tests that need it, instead
> use a weak symbol for get_root_resource and check it at runtime.
> This obviates the need to compile the test sourcce file differently for
> the integrated and standalone cases.
>
> Bug: BLD-325
> Test: CQ
> Change-Id: I48e3f192af87da354f05cd9b75c6e1124d4e2106
TBR=kulakowski@google.com,mcgrathr@google.com,scottmg@google.com,stevensd@google.com
Change-Id: I215e26f0959cc2a5e5caf7c822b3dcc5e14d3625
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: BLD-325
diff --git a/zircon/system/utest/core/pager/pager.cpp b/zircon/system/utest/core/pager/pager.cpp
index 7c32e74..24ffbd7 100644
--- a/zircon/system/utest/core/pager/pager.cpp
+++ b/zircon/system/utest/core/pager/pager.cpp
@@ -15,7 +15,7 @@
#include "userpager.h"
__BEGIN_CDECLS
-__WEAK extern zx_handle_t get_root_resource(void);
+extern zx_handle_t get_root_resource(void);
__END_CDECLS
namespace pager_tests {
@@ -1573,23 +1573,17 @@
ASSERT_EQ(zx_pager_supply_pages(pager.get(), vmo.get(),
0, 0, aux_vmo.get(), 1), ZX_ERR_INVALID_ARGS);
- // The get_root_resource() function is a weak reference here. In the
- // standalone pager-test program, it's not defined because the root
- // resource handle is not available to to the test. In the unified
- // standalone core-tests program, get_root_resource() is available.
- if (&get_root_resource) {
- // unsupported aux vmo type
- zx::vmo physical_vmo;
- // We're not actually going to do anything with this vmo, and since the
- // kernel doesn't do any checks with the address if you're using the
- // root resource, just use addr 0.
- ASSERT_EQ(zx_vmo_create_physical(get_root_resource(), 0, ZX_PAGE_SIZE,
- physical_vmo.reset_and_get_address()),
- ZX_OK);
- ASSERT_EQ(zx_pager_supply_pages(pager.get(), vmo.get(),
- 0, ZX_PAGE_SIZE, physical_vmo.get(), 0),
- ZX_ERR_NOT_SUPPORTED);
- }
+#ifdef BUILD_COMBINED_TESTS
+ // unsupported aux vmo type
+ zx::vmo physical_vmo;
+ // We're not actually going to do anything with this vmo, and since the kernel doesn't
+ // do any checks with the address if you're using the root resource, just use addr 0.
+ ASSERT_EQ(zx_vmo_create_physical(get_root_resource(), 0, ZX_PAGE_SIZE,
+ physical_vmo.reset_and_get_address()),
+ ZX_OK);
+ ASSERT_EQ(zx_pager_supply_pages(pager.get(), vmo.get(),
+ 0, ZX_PAGE_SIZE, physical_vmo.get(), 0), ZX_ERR_NOT_SUPPORTED);
+#endif // BUILD_COMBINED_TESTS
// violations of conditions for taking pages from a vmo
enum PagerViolation {
@@ -1598,14 +1592,12 @@
kHasMapping,
kHasClone,
kNotCommitted,
+#ifdef BUILD_COMBINED_TESTS
kHasPinned,
+#endif // BUILD_COMBINED_TESTS
kViolationCount,
};
for (uint32_t i = 0; i < kViolationCount; i++) {
- if (i == kHasPinned && ! &get_root_resource) {
- continue;
- }
-
zx::vmo aux_vmo; // aux vmo given to supply pages
zx::vmo alt_vmo; // alt vmo if clones are involved
@@ -1639,6 +1631,7 @@
}
}
+#ifdef BUILD_COMBINED_TESTS
zx::iommu iommu;
zx::bti bti;
zx::pmt pmt;
@@ -1651,14 +1644,16 @@
zx_paddr_t addr;
ASSERT_EQ(bti.pin(ZX_BTI_PERM_READ, aux_vmo, 0, ZX_PAGE_SIZE, &addr, 1, &pmt), ZX_OK);
}
+#endif // BUILD_COMBINED_TESTS
ASSERT_EQ(zx_pager_supply_pages(pager.get(), vmo.get(),
- 0, ZX_PAGE_SIZE, aux_vmo.get(), 0),
- ZX_ERR_BAD_STATE);
+ 0, ZX_PAGE_SIZE, aux_vmo.get(), 0), ZX_ERR_BAD_STATE);
+#ifdef BUILD_COMBINED_TESTS
if (pmt) {
pmt.unpin();
}
+#endif // BUILD_COMBINED_TESTS
}
// out of range pager_vmo region
diff --git a/zircon/system/utest/core/pager/test_thread.cpp b/zircon/system/utest/core/pager/test_thread.cpp
index 40c4868..633d44f 100644
--- a/zircon/system/utest/core/pager/test_thread.cpp
+++ b/zircon/system/utest/core/pager/test_thread.cpp
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include <fbl/function.h>
-#include <inspector/inspector.h>
#include <string.h>
#include <threads.h>
#include <zircon/process.h>
@@ -13,6 +12,10 @@
#include <zircon/syscalls/port.h>
#include <zircon/threads.h>
+#ifndef BUILD_COMBINED_TESTS
+#include <inspector/inspector.h>
+#endif
+
#include "test_thread.h"
namespace pager_tests {
@@ -128,6 +131,8 @@
}
void TestThread::PrintDebugInfo(const zx_exception_report_t& report) {
+ // The crash library isn't available when running as part of core-tests
+#ifndef BUILD_COMBINED_TESTS
printf("\nCrash info:\n");
zx_thread_state_general_regs_t regs;
@@ -150,6 +155,7 @@
inspector_dso_print_list(stdout, dso_list);
inspector_print_backtrace(stdout, zx_process_self(), zx_thread_.get(), dso_list,
pc, sp, fp, true);
+#endif
}
bool TestThread::WaitForBlocked() {
diff --git a/zircon/system/utest/core/rules.mk b/zircon/system/utest/core/rules.mk
index ab40bf1..42845eb 100644
--- a/zircon/system/utest/core/rules.mk
+++ b/zircon/system/utest/core/rules.mk
@@ -19,10 +19,8 @@
MODULE_STATIC_LIBS := \
system/ulib/ddk \
- system/ulib/elf-search \
system/ulib/fbl \
system/ulib/fzl \
- system/ulib/inspector \
system/ulib/runtime \
system/ulib/sync \
system/ulib/zx \
@@ -33,13 +31,13 @@
MODULE_STATIC_LIBS += system/utest/core/threads/thread-functions
MODULE_LIBS := \
- third_party/ulib/backtrace \
- third_party/ulib/ngunwind \
system/ulib/unittest \
system/ulib/mini-process \
system/ulib/zircon \
system/ulib/c
+MODULE_DEFINES := BUILD_COMBINED_TESTS=1
+
# core/channel needs a header file generated by kernel/lib/vdso/rules.mk.
MODULE_COMPILEFLAGS += -I$(BUILDDIR)/kernel/lib/vdso
MODULE_SRCDEPS += $(BUILDDIR)/kernel/lib/vdso/vdso-code.h