mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-09-04 20:51:31 +00:00
API: output for [3rd-party] diagnose
This commit provides a minimal output to be displayed when the --quiet flag is used for these commands: - swupd diagnose - swupd 3rd-party diagnose Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit is contained in:
committed by
Castulo J. Martinez
parent
bc58b8bb48
commit
53878d8317
+2
-1
@@ -94,7 +94,8 @@ static bool handle(const char *filename, bool is_dir, bool fix)
|
||||
print(" -> deleted\n");
|
||||
}
|
||||
} else {
|
||||
print(" -> Extra file: %s%s\n", temp, is_dir ? "/" : "");
|
||||
info(" -> Extra file: ");
|
||||
print("%s%s\n", temp, is_dir ? "/" : "");
|
||||
ret = false;
|
||||
}
|
||||
free_and_clear_pointer(&temp);
|
||||
|
||||
+6
-3
@@ -382,7 +382,8 @@ static void add_missing_files(struct manifest *official_manifest, struct list *f
|
||||
counts.missing++;
|
||||
if (!repair || (repair && cmdline_option_install == false)) {
|
||||
/* Log to stdout, so we can post-process */
|
||||
print(" -> Missing file: %s%s", fullname, repair ? "" : "\n");
|
||||
info(" -> Missing file: ");
|
||||
print("%s%s", fullname, repair ? "" : "\n");
|
||||
}
|
||||
} else {
|
||||
goto out;
|
||||
@@ -444,7 +445,8 @@ static void check_and_fix_one(struct file *file, struct manifest *official_manif
|
||||
if (access(fullname, F_OK) == 0) {
|
||||
counts.mismatch++;
|
||||
/* Log to stdout, so we can post-process it */
|
||||
print(" -> Hash mismatch for file: %s%s", fullname, repair ? "" : "\n");
|
||||
info(" -> Hash mismatch for file: ");
|
||||
print("%s%s", fullname, repair ? "" : "\n");
|
||||
}
|
||||
|
||||
/* if not repairing, we're done */
|
||||
@@ -544,7 +546,8 @@ static void remove_orphaned_files(struct list *files_to_verify, bool repair)
|
||||
}
|
||||
|
||||
counts.extraneous++;
|
||||
print(" -> File that should be deleted: %s%s", fullname, repair ? "" : "\n");
|
||||
info(" -> File that should be deleted: ");
|
||||
print("%s%s", fullname, repair ? "" : "\n");
|
||||
|
||||
/* if not repairing, we're done */
|
||||
if (!repair) {
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# Author: Castulo Martinez
|
||||
# Email: castulo.martinez@intel.com
|
||||
|
||||
load "../testlib"
|
||||
|
||||
global_setup() {
|
||||
|
||||
create_test_environment "$TEST_NAME" 10 1
|
||||
|
||||
# add a 3rd-party repo with some "findings" for diagnose
|
||||
create_third_party_repo -a "$TEST_NAME" 10 1 repo1
|
||||
create_bundle -L -t -n test-bundle1 -f /foo/file_1,/bar/file_2 -u repo1 "$TEST_NAME"
|
||||
create_version -p "$TEST_NAME" 20 10 1 repo1
|
||||
update_bundle -p "$TEST_NAME" test-bundle1 --update /foo/file_1 repo1
|
||||
update_bundle -p "$TEST_NAME" test-bundle1 --delete /bar/file_2 repo1
|
||||
update_bundle "$TEST_NAME" test-bundle1 --add /baz/file_3 repo1
|
||||
sudo touch "$TARGETDIR"/"$THIRD_PARTY_BUNDLES_DIR"/repo1/usr/untracked_file
|
||||
set_current_version "$TEST_NAME" 20 repo1
|
||||
|
||||
# add another 3rd-party repo that has nothing to get fixed
|
||||
create_third_party_repo -a "$TEST_NAME" 10 1 repo2
|
||||
create_bundle -L -t -n test-bundle2 -f /baz/file_3 -u repo2 "$TEST_NAME"
|
||||
|
||||
}
|
||||
|
||||
@test "API055: 3rd-party diagnose" {
|
||||
|
||||
run sudo sh -c "$SWUPD 3rd-party diagnose $SWUPD_OPTS --picky --quiet"
|
||||
|
||||
assert_status_is "$SWUPD_NO"
|
||||
expected_output=$(cat <<-EOM
|
||||
[repo1]
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/baz
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/baz/file_3
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/foo/file_1
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/usr/lib/os-release
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/bar/file_2
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/usr/untracked_file
|
||||
[repo2]
|
||||
EOM
|
||||
)
|
||||
assert_is_output "$expected_output"
|
||||
|
||||
}
|
||||
|
||||
@test "API056: 3rd-party diagnose --repo REPOSITORY" {
|
||||
|
||||
run sudo sh -c "$SWUPD 3rd-party diagnose $SWUPD_OPTS --picky --repo repo1 --quiet"
|
||||
|
||||
assert_status_is "$SWUPD_NO"
|
||||
expected_output=$(cat <<-EOM
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/baz
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/baz/file_3
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/foo/file_1
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/usr/lib/os-release
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/bar/file_2
|
||||
$PATH_PREFIX/opt/3rd-party/bundles/repo1/usr/untracked_file
|
||||
EOM
|
||||
)
|
||||
assert_is_output "$expected_output"
|
||||
|
||||
}
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# Author: Castulo Martinez
|
||||
# Email: castulo.martinez@intel.com
|
||||
|
||||
load "../testlib"
|
||||
|
||||
global_setup() {
|
||||
|
||||
create_test_environment -r "$TEST_NAME" 10 1
|
||||
versionurl_hash=$(sudo "$SWUPD" hashdump --quiet "$TARGETDIR"/usr/share/defaults/swupd/versionurl)
|
||||
sudo cp "$TARGETDIR"/usr/share/defaults/swupd/versionurl "$WEBDIR"/10/files/"$versionurl_hash"
|
||||
versionurl="$WEBDIR"/10/files/"$versionurl_hash"
|
||||
contenturl_hash=$(sudo "$SWUPD" hashdump --quiet "$TARGETDIR"/usr/share/defaults/swupd/contenturl)
|
||||
sudo cp "$TARGETDIR"/usr/share/defaults/swupd/contenturl "$WEBDIR"/10/files/"$contenturl_hash"
|
||||
contenturl="$WEBDIR"/10/files/"$contenturl_hash"
|
||||
create_bundle -L -n os-core-update -f /usr/share/defaults/swupd/versionurl:"$versionurl",/usr/share/defaults/swupd/contenturl:"$contenturl" "$TEST_NAME"
|
||||
create_bundle -L -n test-bundle1 -f /foo/file_1,/bar/file_2 "$TEST_NAME"
|
||||
create_version "$TEST_NAME" 20 10 1
|
||||
update_bundle -p "$TEST_NAME" test-bundle1 --update /foo/file_1
|
||||
update_bundle -p "$TEST_NAME" test-bundle1 --delete /bar/file_2
|
||||
update_bundle "$TEST_NAME" test-bundle1 --add /baz/file_3
|
||||
|
||||
}
|
||||
|
||||
@test "API053: diagnose (no issues found)" {
|
||||
|
||||
run sudo sh -c "$SWUPD diagnose $SWUPD_OPTS --picky --quiet"
|
||||
|
||||
assert_status_is "$SWUPD_OK"
|
||||
assert_output_is_empty
|
||||
|
||||
}
|
||||
|
||||
@test "API054: diagnose (issues found)" {
|
||||
|
||||
# set the current version of the target system as if it is already
|
||||
# at version 20 so diagnose find issues
|
||||
set_current_version "$TEST_NAME" 20
|
||||
# adding an untracked file into /usr
|
||||
sudo touch "$TARGETDIR"/usr/untracked_file3
|
||||
|
||||
run sudo sh -c "$SWUPD diagnose $SWUPD_OPTS --picky --quiet"
|
||||
|
||||
assert_status_is "$SWUPD_NO"
|
||||
expected_output=$(cat <<-EOM
|
||||
$PATH_PREFIX/baz
|
||||
$PATH_PREFIX/baz/file_3
|
||||
$PATH_PREFIX/foo/file_1
|
||||
$PATH_PREFIX/usr/lib/os-release
|
||||
$PATH_PREFIX/bar/file_2
|
||||
$PATH_PREFIX/usr/untracked_file3
|
||||
EOM
|
||||
)
|
||||
assert_is_output "$expected_output"
|
||||
|
||||
}
|
||||
@@ -32,11 +32,13 @@ test_setup() {
|
||||
{ "type" : "info", "msg" : " Checking for missing files" },
|
||||
{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 5, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 11, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "info", "msg" : " -> Missing file: $PATH_PREFIX/baz" },
|
||||
{ "type" : "info", "msg" : " -> Missing file:" },
|
||||
{ "type" : "info", "msg" : "$PATH_PREFIX/baz" },
|
||||
{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 17, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 23, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 29, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "info", "msg" : " -> Missing file: $PATH_PREFIX/foo/test-file1" },
|
||||
{ "type" : "info", "msg" : " -> Missing file:" },
|
||||
{ "type" : "info", "msg" : "$PATH_PREFIX/foo/test-file1" },
|
||||
{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 35, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 41, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "progress", "currentStep" : 2, "totalSteps" : 4, "stepCompletion" : 47, "stepDescription" : "add_missing_files" },
|
||||
|
||||
@@ -78,12 +78,14 @@ test_setup() {
|
||||
{ "type" : "info", "msg" : "Adding any missing files" },
|
||||
{ "type" : "progress", "currentStep" : 6, "totalSteps" : 10, "stepCompletion" : 5, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "progress", "currentStep" : 6, "totalSteps" : 10, "stepCompletion" : 11, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "info", "msg" : " -> Missing file: $PATH_PREFIX/baz" },
|
||||
{ "type" : "info", "msg" : " -> Missing file:" },
|
||||
{ "type" : "info", "msg" : "$PATH_PREFIX/baz" },
|
||||
{ "type" : "info", "msg" : " -> fixed" },
|
||||
{ "type" : "progress", "currentStep" : 6, "totalSteps" : 10, "stepCompletion" : 17, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "progress", "currentStep" : 6, "totalSteps" : 10, "stepCompletion" : 23, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "progress", "currentStep" : 6, "totalSteps" : 10, "stepCompletion" : 29, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "info", "msg" : " -> Missing file: $PATH_PREFIX/foo/test-file1" },
|
||||
{ "type" : "info", "msg" : " -> Missing file:" },
|
||||
{ "type" : "info", "msg" : "$PATH_PREFIX/foo/test-file1" },
|
||||
{ "type" : "info", "msg" : " -> fixed" },
|
||||
{ "type" : "progress", "currentStep" : 6, "totalSteps" : 10, "stepCompletion" : 35, "stepDescription" : "add_missing_files" },
|
||||
{ "type" : "progress", "currentStep" : 6, "totalSteps" : 10, "stepCompletion" : 41, "stepDescription" : "add_missing_files" },
|
||||
|
||||
Reference in New Issue
Block a user