Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cf-agent/simulate_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@
GetFileTypeDescription(st_orig.st_mode),
GetFileTypeDescription(st_chrooted.st_mode));
ManifestStatInfo(&st_chrooted);
ManifestFileDetails(path, &st_chrooted, true);
ManifestFileDetails(chrooted_path, &st_chrooted, true);
return true;
}
else
Expand All @@ -459,7 +459,7 @@
default:
printf("'%s' is a %s\n", path, GetFileTypeDescription(st_chrooted.st_mode));
ManifestStatInfo(&st_chrooted);
ManifestFileDetails(path, &st_chrooted, true);
ManifestFileDetails(chrooted_path, &st_chrooted, true);
return true;
}
}
Expand Down
60 changes: 60 additions & 0 deletions tests/acceptance/29_simulate_mode/diff_mode_symlinks.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
body common control
{
inputs => { "../default.sub.cf" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

bundle agent init
{
files:
"$(G.testroot)/target-old" create => "true";
"$(G.testroot)/target-new" create => "true";

"$(G.testroot)/wrong-target"
link_from => linkfrom("$(G.testroot)/target-old", "symlink");

"$(G.testroot)/obstruction"
create => "true",
content => "I am in the way";
}

bundle agent test
{
meta:
"test_soft_fail"
string => "(solaris|aix|hpux|windows)",
# ENT-6540 exotics fail to delete chroot
# ENT-10254 tests fail on Windows due to CRLF
meta => { "ENT-6540", "ENT-10254" };

"description" -> { "ENT-14713" }
string => "Test that --simulate=diff shows the new target of a symlink that replaced a wrong link or an obstructing file";
}

bundle agent check
{
vars:
"command"
string => "$(sys.cf_agent) -Kf $(this.promise_filename).sub --simulate=diff";

"new_target" string => "\QTarget: '$(G.testroot)/target-new'\E";

# Bound the gap to one file's section (6 output lines today, +1 slack)
"same_section" string => "\n(?:[^\n]*\n){0,7}";

"wanted"
string => concat(
".*\Q'$(G.testroot)/wrong-target' is a symbolic link\E$(same_section)$(new_target)",
".*\Q'$(G.testroot)/obstruction' changed type from regular file to symbolic link\E$(same_section)$(new_target).*"
);

methods:
"check"
usebundle => dcs_passif_output(
$(wanted),
".*(Invalid target|Target: '[^/]).*",
$(command),
$(this.promise_filename)
);
}
15 changes: 15 additions & 0 deletions tests/acceptance/29_simulate_mode/diff_mode_symlinks.cf.sub
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
body common control
{
inputs => { "../default.sub.cf" };
}

bundle agent main
{
files:
"$(G.testroot)/wrong-target"
link_from => linkfrom("$(G.testroot)/target-new", "symlink"),
move_obstructions => "true";
"$(G.testroot)/obstruction"
link_from => linkfrom("$(G.testroot)/target-new", "symlink"),
move_obstructions => "true";
}
Loading