selftest: Fix selftest to check ADS functionalty again
authorAndrew Bartlett <abartlet@samba.org>
Fri, 17 Feb 2012 23:35:24 +0000 (10:35 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 17 Feb 2012 23:44:07 +0000 (00:44 +0100)
This was found by looking over the lcov output on build.samba.org

The new have_ads() check also now dies if it cannot run smbd, to avoid
this in future.

Andrew Bartlett

selftest/target/Samba3.pm

index e8a03e7..2696014 100755 (executable)
@@ -12,15 +12,17 @@ use POSIX;
 use target::Samba;
 
 sub have_ads($) {
-    my ($self);
+        my ($self) = @_;
        my $found_ads = 0;
-       my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b";
-       my @build_options = `$smbd_build_options`;
-       foreach my $option (@build_options) {
-               if ($option =~ "WITH_ADS") {
-                      $found_ads = 1;
-               }
-       }
+        my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|";
+        open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!");
+
+        while (<IN>) {
+                if (/WITH_ADS/) {
+                       $found_ads = 1;
+                }
+        }
+       close IN;
 
        # If we were not built with ADS support, pretend we were never even available
        return $found_ads;