anchor.diff:          # occur, so all machines in the network are valid candidate hosts.
           # This test should succeed.
   
  -        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist --filter-buildable -s ${tests}/services.nix -i ${tests}/infrastructure.nix");
  -        my @distribution = split('\n', $machine->mustSucceed("cat $result"));
  -
  -        if($distribution[5] =~ /testtarget1/) {
  -            print "line 5 contains testtarget1!\n";
  -        } else {
  -            die "line 5 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[6] =~ /testtarget2/) {
  -            print "line 6 contains testtarget2!\n";
  -        } else {
  -            die "line 6 should contain testtarget2!\n";
  -        }
  -
  -        if($distribution[9] =~ /testtarget1/) {
  -            print "line 9 contains testtarget1!\n";
  -        } else {
  -            die "line 9 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[10] =~ /testtarget2/) {
  -            print "line 10 contains testtarget2!\n";
  -        } else {
  -            die "line 10 should contain testtarget2!\n";
  -        }
  -
  -        if($distribution[13] =~ /testtarget1/) {
  -            print "line 13 contains testtarget1!\n";
  -        } else {
  -            die "line 13 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[14] =~ /testtarget2/) {
  -            print "line 14 contains testtarget2!\n";
  -        } else {
  -            die "line 14 should contain testtarget2!\n";
  -        }
  +        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist --filter-buildable -s ${tests}/services.nix -i ${tests}/infrastructure.nix --output-xml");
  +
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget2']\" result");
   
           # Execute filter buildable. In this situation a build exception is
           # thrown for testService1B rendering it undeployable.
           # This test should succeed.
   
  -        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist --filter-buildable -s ${tests}/services-error.nix -i ${tests}/infrastructure.nix");
  -        @distribution = split('\n', $machine->mustSucceed("cat $result"));
  -
  -        if($distribution[5] =~ /testtarget1/) {
  -            die "line 5 contains testtarget1!\n";
  -        } else {
  -            print "line 5 should contain testtarget1!\n";
  -        }
  +        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist --filter-buildable -s ${tests}/services-error.nix -i ${tests}/infrastructure.nix --output-xml");
  +
  +        $machine->mustFail("xmllint --xpath \"/distribution/service[\@name='testService1B']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustFail("xmllint --xpath \"/distribution/service[\@name='testService1B']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget2']\" result");
   
           # Execute the mapAttrOnAttr method to map requireZone onto zone.
           # testService1 should be assigned to testtarget1. testService2 and
           # testService3 should be assigned to testtarget2. This test should
           # succeed.
   
  -        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-mapattronattr.nix");
  -        @distribution = split('\n', $machine->mustSucceed("cat $result"));
  -
  -        if($distribution[5] =~ /testtarget1/) {
  -            print "line 5 contains testtarget1!\n";
  -        } else {
  -            die "line 5 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[8] =~ /testtarget1/) {
  -            print "line 8 contains testtarget1!\n";
  -        } else {
  -            die "line 8 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[11] =~ /testtarget2/) {
  -            print "line 11 contains testtarget2!\n";
  -        } else {
  -            die "line 11 should contain testtarget2!\n";
  -        }
  +        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-mapattronattr.nix --output-xml");
  +
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustFail("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustFail("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustFail("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget2']\" result");
   
           # Execute the mapAttrOnList method to map types onto supportedTypes.
           # All services must be assigned to both testtarget1 and testtarget2.
           # This test should succeed.
   
  -        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-mapattronlist.nix");
  -        @distribution = split('\n', $machine->mustSucceed("cat $result"));
  -
  -        if($distribution[5] =~ /testtarget1/) {
  -            print "line 5 contains testtarget1!\n";
  -        } else {
  -            die "line 5 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[6] =~ /testtarget2/) {
  -            print "line 6 contains testtarget2!\n";
  -        } else {
  -            die "line 6 should contain testtarget2!\n";
  -        }
  -
  -        if($distribution[9] =~ /testtarget1/) {
  -            print "line 9 contains testtarget1!\n";
  -        } else {
  -            die "line 9 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[10] =~ /testtarget2/) {
  -            print "line 10 contains testtarget1!\n";
  -        } else {
  -            die "line 10 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[13] =~ /testtarget1/) {
  -            print "line 13 contains testtarget1!\n";
  -        } else {
  -            die "line 13 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[14] =~ /testtarget2/) {
  -            print "line 14 contains testtarget2!\n";
  -        } else {
  -            die "line 14 should contain testtarget2!\n";
  -        }
  +        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-mapattronlist.nix --output-xml");
  +
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget2']\" result");
   
           # Execute the mapListOnAttr method to map requiredZones onto zones.
           # testService1 must be assigned to testtarget1. testService2 must be
           # assigned to testtarget2. testService3 must be assigned to both
           # machines. This test should succeed.
   
  -        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-maplistonattr.nix");
  -        @distribution = split('\n', $machine->mustSucceed("cat $result"));
  -
  -        if($distribution[5] =~ /testtarget1/) {
  -            print "line 5 contains testtarget1!\n";
  -        } else {
  -            die "line 5 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[8] =~ /testtarget2/) {
  -            print "line 8 contains testtarget2!\n";
  -        } else {
  -            die "line 8 should contain testtarget2!\n";
  -        }
  -
  -        if($distribution[11] =~ /testtarget1/) {
  -            print "line 11 contains testtarget1!\n";
  -        } else {
  -            die "line 11 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[12] =~ /testtarget2/) {
  -            print "line 12 contains testtarget2!\n";
  -        } else {
  -            die "line 12 should contain testtarget2!\n";
  -        }
  +        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-maplistonattr.nix --output-xml");
  +
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustFail("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustFail("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget2']\" result");
   
           # Execute order. The targets are order by looking to the priority
           # attribute. The order of the targets should be reversed.
           # This test should succeed.
   
  -        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-order.nix");
  -        @distribution = split('\n', $machine->mustSucceed("cat $result"));
  -
  -        if($distribution[5] =~ /testtarget2/) {
  -            print "line 5 contains testtarget2!\n";
  -        } else {
  -            die "line 5 should contain testtarget2!\n";
  -        }
  -
  -        if($distribution[6] =~ /testtarget1/) {
  -            print "line 6 contains testtarget1!\n";
  -        } else {
  -            die "line 6 should contain testtarget1!\n";
  -        }
  +        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-order.nix --output-xml");
  +
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping[1]/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping[2]/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping[1]/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping[2]/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping[1]/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping[2]/target[text() = 'testtarget1']\" result");
   
           # Execute the greedy division method. testService1 and testService2
           # should be assigned to testtarget2. testService3 should be assigned
           # to testtarget1. This test should succeed.
   
  -        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-greedy.nix");
  -        @distribution = split('\n', $machine->mustSucceed("cat $result"));
  -
  -        if($distribution[5] =~ /testtarget1/) {
  -            print "line 5 contains testtarget1!\n";
  -        } else {
  -            die "line 5 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[8] =~ /testtarget1/) {
  -            print "line 8 contains testtarget1!\n";
  -        } else {
  -            die "line 8 should contain testtarget1!\n";
  -        }
  -
  -        if($distribution[11] =~ /testtarget2/) {
  -            print "line 11 contains testtarget2!\n";
  -        } else {
  -            die "line 11 should contain testtarget2!\n";
  -        }
  +        $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-greedy.nix --output-xml");
  +
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustFail("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustFail("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget2']\" result");
  +        $machine->mustFail("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget1']\" result");
  +        $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget2']\" result");
   
           # Execute the same division method again. It should fail because the machines cannot provide its required capacity.
           $machine->mustFail("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure-undercapacity.nix -q ${tests}/qos/qos-greedy.nix");
  
positive.code:         # targettarget1. testService3 should be assigned to testtarget2.
          # This test should succeed.
  
          $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-highest-bidder.nix");
          @distribution = split('\n', $machine->mustSucceed("cat $result"));
  
          if($distribution[5] =~ /testtarget2/) {
              print "line 5 contains testtarget2!\n";
          } else {
              die "line 5 should contain testtarget2!\n";
          }
  
          if($distribution[8] =~ /testtarget1/) {
              print "line 8 contains testtarget1!\n";
          } else {
              die "line 8 should contain testtarget1!\n";
          }
  
          if($distribution[11] =~ /testtarget2/) {
              print "line 11 contains testtarget2!\n";
          } else {
              die "line 11 should contain testtarget2!\n";
          }
  
          # Execute the same division method again. It should fail because the machines cannot provide its required capacity.
          $machine->mustFail("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure-undercapacity.nix -q ${tests}/qos/qos-highest-bidder.nix");
  
negative.code:         $machine->mustSucceed("mkdir /nix/var/nix/profiles/per-user/root/disnix-coordinator");
          $machine->mustSucceed("nix-env -p /nix/var/nix/profiles/per-user/root/disnix-coordinator/default --set $result");
  
          $result = $machine->mustSucceed("NIX_PATH='nixpkgs=${nixpkgs}' dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q ${tests}/qos/qos-mapstatefultoprevious.nix --output-xml");
  
          $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget1']\" result");
          $machine->mustFail("xmllint --xpath \"/distribution/service[\@name='testService1']/mapping/target[text() = 'testtarget2']\" result");
          $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget1']\" result");
          $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService2']/mapping/target[text() = 'testtarget2']\" result");
          $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget1']\" result");
          $machine->mustSucceed("xmllint --xpath \"/distribution/service[\@name='testService3']/mapping/target[text() = 'testtarget2']\" result");
  
          # Execute map bind service to previous test. We first deploy all
          # services to test1. Then we deploy again and check whether all
  