Module records and aliases
Installation records what a module reports about itself. dpm_install_module opens a module once, writes its version and description to a .meta file in /var/lib/dpm/metadata/, and records the alternate names it declared in modules.aliases beside it. dpm_uninstall_module removes both, leaving the module file in place. dpm_list_modules reads those records and opens no module. A module with no record lists with a version of <uninstalled> and still loads when a caller names it. An unreadable or absent metadata directory costs the listing its detail and costs nothing else. Aliases give a module alternate names, declared through the new dpm_module_aliases contract symbol or added with dpm_add_module_alias. A name is recorded once: one already serving as an alias, or belonging to an installed module, is refused rather than repointed. dpm_require matches a name against the installed modules, then the alias table, then the module path. The metadata directory is a fifth override field and the -M flag, and [modules] metadata in core.conf. The test suite is four binaries covering context, modules, records, and aliases, each a ctest case of its own, alongside the CLI cases.
This commit is contained in:
2
tests/fixtures/metadata/good.meta
vendored
Normal file
2
tests/fixtures/metadata/good.meta
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
version = 1.2.3
|
||||
description = Known-good stub module.
|
||||
2
tests/fixtures/metadata/modules.aliases
vendored
Normal file
2
tests/fixtures/metadata/modules.aliases
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
goodie = good
|
||||
gd = good
|
||||
4
tests/fixtures/src/bad_version.cpp
vendored
4
tests/fixtures/src/bad_version.cpp
vendored
@@ -28,6 +28,10 @@ extern "C" const char* dpm_module_description(void) {
|
||||
return "Fixture with a malformed version.";
|
||||
}
|
||||
|
||||
extern "C" const char* dpm_module_aliases(void) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
extern "C" int dpm_module_execute(void* ctx, const char* command,
|
||||
int argc, char** argv) {
|
||||
(void)ctx;
|
||||
|
||||
6
tests/fixtures/src/good.cpp
vendored
6
tests/fixtures/src/good.cpp
vendored
@@ -32,6 +32,12 @@ extern "C" const char* dpm_module_description(void) {
|
||||
return "Known-good stub module.";
|
||||
}
|
||||
|
||||
/* Declares two alternate names, so alias recording is exercised against
|
||||
a module that reports more than one. */
|
||||
extern "C" const char* dpm_module_aliases(void) {
|
||||
return "goodie, gd";
|
||||
}
|
||||
|
||||
/* Answers "ping" with 42 so a dispatch round trip is observable, and
|
||||
0 for anything else. */
|
||||
extern "C" int dpm_module_execute(void* ctx, const char* command,
|
||||
|
||||
5
tests/fixtures/src/missing_symbols.cpp
vendored
5
tests/fixtures/src/missing_symbols.cpp
vendored
@@ -2,8 +2,9 @@
|
||||
* @file missing_symbols.cpp
|
||||
* @brief Broken fixture: exports only part of the module contract
|
||||
*
|
||||
* Exports the version and description probes and nothing else.
|
||||
* libdpm-core.so refuses it at step 1 and names dpm_module_execute.
|
||||
* Exports the version and description probes and nothing else, so two
|
||||
* of the four reserved contract symbols are absent. libdpm-core.so
|
||||
* refuses it at step 1 and names both.
|
||||
*
|
||||
* Part of the Dark Horse Linux Package Manager (DPM)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user