@@ -286,11 +286,185 @@ tc6_body() {
286286 atf_check_equal $rval 0
287287}
288288
289+ # 7th test: unmodified configuration file on disk, modified on upgrade.
290+ # result: update file
291+ atf_test_case tc7
292+
293+ tc7_head () {
294+ atf_set " descr" " Tests for configuration file handling: on-disk unmodified, upgrade modified"
295+ }
296+
297+ tc7_body () {
298+ mkdir repo
299+ cd repo
300+ mkdir pkg_a
301+ echo " original" > pkg_a/cf1.conf
302+ chmod 644 pkg_a/cf1.conf
303+ xbps-create -A noarch -n a-0.1_1 -s " pkg a" --config-files " /cf1.conf" pkg_a
304+ atf_check_equal $? 0
305+ rm -rf pkg_a
306+ xbps-rindex -d -a $PWD /* .xbps
307+ atf_check_equal $? 0
308+ cd ..
309+
310+ xbps-install -C xbps.d -r rootdir --repository=$PWD /repo -yvd a
311+ atf_check_equal $? 0
312+
313+ cd repo
314+ mkdir pkg_a
315+ echo " updated" > pkg_a/cf1.conf
316+ chmod 644 pkg_a/cf1.conf
317+ xbps-create -A noarch -n a-0.2_1 -s " pkg a" --config-files " /cf1.conf" pkg_a
318+ atf_check_equal $? 0
319+ xbps-rindex -d -a $PWD /* .xbps
320+ rm -rf pkg_a
321+ atf_check_equal $? 0
322+ cd ..
323+
324+ xbps-install -C xbps.d -r rootdir --repository=$PWD /repo -yuvd
325+ atf_check_equal $? 0
326+ atf_check_equal " $( cat rootdir/cf1.conf) " " updated"
327+ }
328+
329+ # 8th test: modified configuration file on disk to same as updated, modified on upgrade.
330+ # result: keep on-disk file as is, don't install new conf file as file.new-<version>.
331+ atf_test_case tc8
332+
333+ tc8_head () {
334+ atf_set " descr" " Tests for configuration file handling: on-disk modified, matches upgrade"
335+ }
336+
337+ tc8_body () {
338+ mkdir repo
339+ cd repo
340+ mkdir pkg_a
341+ echo " original" > pkg_a/cf1.conf
342+ chmod 644 pkg_a/cf1.conf
343+ xbps-create -A noarch -n a-0.1_1 -s " pkg a" --config-files " /cf1.conf" pkg_a
344+ atf_check_equal $? 0
345+ rm -rf pkg_a
346+ xbps-rindex -d -a $PWD /* .xbps
347+ atf_check_equal $? 0
348+ cd ..
349+
350+ xbps-install -C xbps.d -r rootdir --repository=$PWD /repo -yvd a
351+ atf_check_equal $? 0
352+ sed -e ' s,original,improved,' -i rootdir/cf1.conf
353+
354+ cd repo
355+ mkdir pkg_a
356+ echo " improved" > pkg_a/cf1.conf
357+ chmod 644 pkg_a/cf1.conf
358+ xbps-create -A noarch -n a-0.2_1 -s " pkg a" --config-files " /cf1.conf" pkg_a
359+ atf_check_equal $? 0
360+ xbps-rindex -d -a $PWD /* .xbps
361+ rm -rf pkg_a
362+ atf_check_equal $? 0
363+ cd ..
364+
365+ xbps-install -C xbps.d -r rootdir --repository=$PWD /repo -yuvd
366+ atf_check_equal $? 0
367+ atf_check_equal " $( cat rootdir/cf1.conf) " " improved"
368+ test ' !' -e rootdir/cf1.conf.new-0.2_1
369+ atf_check_equal $? 0
370+ }
371+
372+ # 9th test: removed configuration file on disk, unmodified on upgrade.
373+ # result: install file
374+ atf_test_case tc9
375+
376+ tc9_head () {
377+ atf_set " descr" " Tests for configuration file handling: on-disk removed, upgrade unmodified"
378+ }
379+
380+ tc9_body () {
381+ mkdir repo
382+ cd repo
383+ mkdir pkg_a
384+ echo " original" > pkg_a/cf1.conf
385+ chmod 644 pkg_a/cf1.conf
386+ xbps-create -A noarch -n a-0.1_1 -s " pkg a" --config-files " /cf1.conf" pkg_a
387+ atf_check_equal $? 0
388+ rm -rf pkg_a
389+ xbps-rindex -d -a $PWD /* .xbps
390+ atf_check_equal $? 0
391+ cd ..
392+
393+ xbps-install -C xbps.d -r rootdir --repository=$PWD /repo -yvd a
394+ atf_check_equal $? 0
395+ rm rootdir/cf1.conf
396+
397+ cd repo
398+ mkdir pkg_a
399+ echo " original" > pkg_a/cf1.conf
400+ chmod 644 pkg_a/cf1.conf
401+ xbps-create -A noarch -n a-0.2_1 -s " pkg a" --config-files " /cf1.conf" pkg_a
402+ atf_check_equal $? 0
403+ xbps-rindex -d -a $PWD /* .xbps
404+ rm -rf pkg_a
405+ atf_check_equal $? 0
406+ cd ..
407+
408+ xbps-install -C xbps.d -r rootdir --repository=$PWD /repo -yuvd
409+ atf_check_equal $? 0
410+ atf_check_equal " $( cat rootdir/cf1.conf) " " original"
411+ test ' !' -e rootdir/cf1.conf.new-0.2_1
412+ atf_check_equal $? 0
413+ }
414+
415+
416+ # 10th test: removed configuration file on disk, modified on upgrade.
417+ # result: install file
418+ atf_test_case tc10
419+
420+ tc10_head () {
421+ atf_set " descr" " Tests for configuration file handling: on-disk removed, upgrade modified"
422+ }
423+
424+ tc10_body () {
425+ mkdir repo
426+ cd repo
427+ mkdir pkg_a
428+ echo " original" > pkg_a/cf1.conf
429+ chmod 644 pkg_a/cf1.conf
430+ xbps-create -A noarch -n a-0.1_1 -s " pkg a" --config-files " /cf1.conf" pkg_a
431+ atf_check_equal $? 0
432+ rm -rf pkg_a
433+ xbps-rindex -d -a $PWD /* .xbps
434+ atf_check_equal $? 0
435+ cd ..
436+
437+ xbps-install -C xbps.d -r rootdir --repository=$PWD /repo -yvd a
438+ atf_check_equal $? 0
439+ rm rootdir/cf1.conf
440+
441+ cd repo
442+ mkdir pkg_a
443+ echo " updated" > pkg_a/cf1.conf
444+ chmod 644 pkg_a/cf1.conf
445+ xbps-create -A noarch -n a-0.2_1 -s " pkg a" --config-files " /cf1.conf" pkg_a
446+ atf_check_equal $? 0
447+ xbps-rindex -d -a $PWD /* .xbps
448+ rm -rf pkg_a
449+ atf_check_equal $? 0
450+ cd ..
451+
452+ xbps-install -C xbps.d -r rootdir --repository=$PWD /repo -yuvd
453+ atf_check_equal $? 0
454+ atf_check_equal " $( cat rootdir/cf1.conf) " " updated"
455+ test ' !' -e rootdir/cf1.conf.new-0.2_1
456+ atf_check_equal $? 0
457+ }
458+
289459atf_init_test_cases () {
290460 atf_add_test_case tc1
291461 atf_add_test_case tc2
292462 atf_add_test_case tc3
293463 atf_add_test_case tc4
294464 atf_add_test_case tc5
295465 atf_add_test_case tc6
466+ atf_add_test_case tc7
467+ atf_add_test_case tc8
468+ atf_add_test_case tc9
469+ atf_add_test_case tc10
296470}
0 commit comments