#!/usr/bin/perl use Libconf qw(:functions); use Data::Dumper; # test 1, minimal requirement : regenerate correctly display(1); my $struct = new Libconf('level.local', 'fonctionvalue', ''); #print Dumper($struct) . "\n"; $struct->writeConf("msec_output_1"); test(1); # test 2, test for stable loop display(2); $struct = new Libconf('level.local', 'fonctionvalue', ''); $struct->writeConf("msec_output_2"); $struct = new Libconf('msec_output_2', 'fonctionvalue', ''); $struct->writeConf("msec_output_2"); test(2); # test 3, editing an atom display(3); my $struct = new Libconf('level.local', 'fonctionvalue', ''); $struct->editAtom(-1, {key => 'enable_ip_spoofing_protection', value => 'no' }); $struct->writeConf("msec_output_3"); test(3); display(-1); sub display { local $| = 1; $_[0] == -1 ? print " done\n" : print "\r * testing postfix " . '.' x $_[0]; local $| = 0; } sub test { my ($num, $exec) = @_; $exec ||= "diff -q msec_output_$num msec_verify_$num 2>/dev/null 1>/dev/null"; if (system($exec) != 0) { print "\r * testing msec : TEST N°$num FAILED\n"; exit($!); } }