#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;

chdir("logger") or die "chdir testdir failed: $!\n";

require TestDriver;

my $td = new TestDriver('logger');

cleanup();

$td->runtest("logger",
             {$td->COMMAND => "logger >stdout 2>stderr"},
             {$td->STRING => "", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check stdout",
             {$td->FILE => "stdout"},
             {$td->FILE => "exp-stdout"},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check stderr",
             {$td->FILE => "stderr"},
             {$td->FILE => "exp-stderr"},
             $td->NORMALIZE_NEWLINES);

$td->runtest("logger C API",
             {$td->COMMAND => "logger_c >stdout 2>stderr"},
             {$td->STRING => "", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
foreach my $f (qw(stdout stderr info warn error save save2))
{
    $td->runtest("check $f (C)",
                 {$td->FILE => "$f"},
                 {$td->FILE => "c-exp-$f"},
                 $td->NORMALIZE_NEWLINES);
}

cleanup();
$td->report(11);

sub cleanup
{
    unlink "stdout", "stderr", "info", "warn", "error", "save", "save2";
}
