head	1.3;
access;
symbols
	perseant-exfatfs-base-20261102:1.3
	netbsd-11-1-RELEASE:1.3
	netbsd-10-2-RELEASE:1.3
	netbsd-9-5-RELEASE:1.3
	netbsd-11-0-RELEASE:1.3
	netbsd-11-0-RC7:1.3
	netbsd-11-0-RC6:1.3
	netbsd-11-0-RC5:1.3
	netbsd-11-0-RC4:1.3
	netbsd-11-0-RC3:1.3
	netbsd-11-0-RC2:1.3
	netbsd-11-0-RC1:1.3
	perseant-exfatfs-base-20250801:1.3
	netbsd-11:1.3.0.56
	netbsd-11-base:1.3
	netbsd-10-1-RELEASE:1.3
	perseant-exfatfs-base-20240630:1.3
	perseant-exfatfs:1.3.0.54
	perseant-exfatfs-base:1.3
	netbsd-8-3-RELEASE:1.3
	netbsd-9-4-RELEASE:1.3
	netbsd-10-0-RELEASE:1.3
	netbsd-10-0-RC6:1.3
	netbsd-10-0-RC5:1.3
	netbsd-10-0-RC4:1.3
	netbsd-10-0-RC3:1.3
	netbsd-10-0-RC2:1.3
	netbsd-10-0-RC1:1.3
	netbsd-10:1.3.0.52
	netbsd-10-base:1.3
	netbsd-9-3-RELEASE:1.3
	cjep_sun2x-base1:1.3
	cjep_sun2x:1.3.0.50
	cjep_sun2x-base:1.3
	cjep_staticlib_x-base1:1.3
	netbsd-9-2-RELEASE:1.3
	cjep_staticlib_x:1.3.0.48
	cjep_staticlib_x-base:1.3
	netbsd-9-1-RELEASE:1.3
	phil-wifi-20200421:1.3
	phil-wifi-20200411:1.3
	is-mlppp:1.3.0.46
	is-mlppp-base:1.3
	phil-wifi-20200406:1.3
	netbsd-8-2-RELEASE:1.3
	netbsd-9-0-RELEASE:1.3
	netbsd-9-0-RC2:1.3
	netbsd-9-0-RC1:1.3
	phil-wifi-20191119:1.3
	netbsd-9:1.3.0.44
	netbsd-9-base:1.3
	phil-wifi-20190609:1.3
	netbsd-8-1-RELEASE:1.3
	netbsd-8-1-RC1:1.3
	pgoyette-compat-merge-20190127:1.3
	pgoyette-compat-20190127:1.3
	pgoyette-compat-20190118:1.3
	pgoyette-compat-1226:1.3
	pgoyette-compat-1126:1.3
	pgoyette-compat-1020:1.3
	pgoyette-compat-0930:1.3
	pgoyette-compat-0906:1.3
	netbsd-7-2-RELEASE:1.3
	pgoyette-compat-0728:1.3
	netbsd-8-0-RELEASE:1.3
	phil-wifi:1.3.0.42
	phil-wifi-base:1.3
	pgoyette-compat-0625:1.3
	netbsd-8-0-RC2:1.3
	pgoyette-compat-0521:1.3
	pgoyette-compat-0502:1.3
	pgoyette-compat-0422:1.3
	netbsd-8-0-RC1:1.3
	pgoyette-compat-0415:1.3
	pgoyette-compat-0407:1.3
	pgoyette-compat-0330:1.3
	pgoyette-compat-0322:1.3
	pgoyette-compat-0315:1.3
	netbsd-7-1-2-RELEASE:1.3
	pgoyette-compat:1.3.0.40
	pgoyette-compat-base:1.3
	netbsd-7-1-1-RELEASE:1.3
	matt-nb8-mediatek:1.3.0.38
	matt-nb8-mediatek-base:1.3
	perseant-stdc-iso10646:1.3.0.36
	perseant-stdc-iso10646-base:1.3
	netbsd-8:1.3.0.34
	netbsd-8-base:1.3
	prg-localcount2-base3:1.3
	prg-localcount2-base2:1.3
	prg-localcount2-base1:1.3
	prg-localcount2:1.3.0.32
	prg-localcount2-base:1.3
	pgoyette-localcount-20170426:1.3
	bouyer-socketcan-base1:1.3
	pgoyette-localcount-20170320:1.3
	netbsd-7-1:1.3.0.30
	netbsd-7-1-RELEASE:1.3
	netbsd-7-1-RC2:1.3
	netbsd-7-nhusb-base-20170116:1.3
	bouyer-socketcan:1.3.0.28
	bouyer-socketcan-base:1.3
	pgoyette-localcount-20170107:1.3
	netbsd-7-1-RC1:1.3
	pgoyette-localcount-20161104:1.3
	netbsd-7-0-2-RELEASE:1.3
	localcount-20160914:1.3
	netbsd-7-nhusb:1.3.0.26
	netbsd-7-nhusb-base:1.3
	pgoyette-localcount-20160806:1.3
	pgoyette-localcount-20160726:1.3
	pgoyette-localcount:1.3.0.24
	pgoyette-localcount-base:1.3
	netbsd-7-0-1-RELEASE:1.3
	netbsd-7-0:1.3.0.22
	netbsd-7-0-RELEASE:1.3
	netbsd-7-0-RC3:1.3
	netbsd-7-0-RC2:1.3
	netbsd-7-0-RC1:1.3
	netbsd-6-0-6-RELEASE:1.3
	netbsd-6-1-5-RELEASE:1.3
	netbsd-7:1.3.0.20
	netbsd-7-base:1.3
	yamt-pagecache-base9:1.3
	yamt-pagecache-tag8:1.1.1.1.6.1
	netbsd-6-1-4-RELEASE:1.3
	netbsd-6-0-5-RELEASE:1.3
	tls-earlyentropy:1.3.0.18
	tls-earlyentropy-base:1.3
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.3
	riastradh-drm2-base3:1.3
	atf-0-20:1.1.1.2
	atf-0-19:1.1.1.2
	GITHUB_JMMV:1.1.1
	netbsd-6-1-3-RELEASE:1.3
	netbsd-6-0-4-RELEASE:1.3
	netbsd-6-1-2-RELEASE:1.3
	netbsd-6-0-3-RELEASE:1.3
	netbsd-6-1-1-RELEASE:1.3
	riastradh-drm2-base2:1.3
	riastradh-drm2-base1:1.3
	riastradh-drm2:1.3.0.10
	riastradh-drm2-base:1.3
	netbsd-6-1:1.3.0.16
	netbsd-6-0-2-RELEASE:1.3
	netbsd-6-1-RELEASE:1.3
	khorben-n900:1.3.0.14
	netbsd-6-1-RC4:1.3
	netbsd-6-1-RC3:1.3
	agc-symver:1.3.0.12
	agc-symver-base:1.3
	netbsd-6-1-RC2:1.3
	netbsd-6-1-RC1:1.3
	atf-0-17:1.1.1.2
	yamt-pagecache-base8:1.3
	netbsd-6-0-1-RELEASE:1.3
	yamt-pagecache-base7:1.3
	matt-nb6-plus-nbase:1.3
	yamt-pagecache-base6:1.3
	netbsd-6-0:1.3.0.8
	netbsd-6-0-RELEASE:1.3
	netbsd-6-0-RC2:1.3
	tls-maxphys:1.3.0.6
	tls-maxphys-base:1.3
	matt-nb6-plus:1.3.0.4
	matt-nb6-plus-base:1.3
	netbsd-6-0-RC1:1.3
	atf-0-16:1.1.1.2
	yamt-pagecache-base5:1.3
	yamt-pagecache-base4:1.3
	netbsd-6:1.3.0.2
	netbsd-6-base:1.3
	atf-0-15:1.1.1.2
	yamt-pagecache-base3:1.1.1.1
	yamt-pagecache-base2:1.1.1.1
	yamt-pagecache:1.1.1.1.0.6
	yamt-pagecache-base:1.1.1.1
	atf-0-14:1.1.1.1
	cherry-xenmp:1.1.1.1.0.4
	cherry-xenmp-base:1.1.1.1
	atf-0-13:1.1.1.1
	bouyer-quota2-nbase:1.1.1.1
	bouyer-quota2:1.1.1.1.0.2
	bouyer-quota2-base:1.1.1.1
	matt-mips64-premerge-20101231:1.1.1.1
	atf-0-12:1.1.1.1
	atf-0-11:1.1.1.1
	TNF:1.1.1;
locks; strict;
comment	@// @;


1.3
date	2012.01.16.22.41.30;	author jmmv;	state Exp;
branches;
next	1.2;

1.2
date	2011.11.16.17.46.16;	author christos;	state Exp;
branches;
next	1.1;

1.1
date	2010.10.20.09.14.21;	author jmmv;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2010.10.20.09.14.21;	author jmmv;	state Exp;
branches
	1.1.1.1.6.1;
next	1.1.1.2;

1.1.1.2
date	2012.01.16.22.36.46;	author jmmv;	state Exp;
branches;
next	;

1.1.1.1.6.1
date	2012.04.17.00.03.02;	author yamt;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Resolve conflicts after the import of atf 0.15.
@
text
@//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

extern "C" {
#include <regex.h>
}

#include <cctype>
#include <cstring>

extern "C" {
#include "../../atf-c/error.h"

#include "../../atf-c/detail/text.h"
}

#include "exceptions.hpp"
#include "text.hpp"

namespace impl = atf::text;
#define IMPL_NAME "atf::text"

char*
impl::duplicate(const char* str)
{
    char* copy = new char[std::strlen(str) + 1];
    std::strcpy(copy, str);
    return copy;
}

bool
impl::match(const std::string& str, const std::string& regex)
{
    bool found;

    // Special case: regcomp does not like empty regular expressions.
    if (regex.empty()) {
        found = str.empty();
    } else {
        ::regex_t preg;

        if (::regcomp(&preg, regex.c_str(), REG_EXTENDED) != 0)
            throw std::runtime_error("Invalid regular expression '" + regex +
                                     "'");

        const int res = ::regexec(&preg, str.c_str(), 0, NULL, 0);
        regfree(&preg);
        if (res != 0 && res != REG_NOMATCH)
            throw std::runtime_error("Invalid regular expression " + regex);

        found = res == 0;
    }

    return found;
}

std::string
impl::to_lower(const std::string& str)
{
    std::string lc;
    for (std::string::const_iterator iter = str.begin(); iter != str.end();
         iter++)
        lc += std::tolower(*iter);
    return lc;
}

std::vector< std::string >
impl::split(const std::string& str, const std::string& delim)
{
    std::vector< std::string > words;

    std::string::size_type pos = 0, newpos = 0;
    while (pos < str.length() && newpos != std::string::npos) {
        newpos = str.find(delim, pos);
        if (newpos != pos)
            words.push_back(str.substr(pos, newpos - pos));
        pos = newpos + delim.length();
    }

    return words;
}

std::string
impl::trim(const std::string& str)
{
    std::string::size_type pos1 = str.find_first_not_of(" \t");
    std::string::size_type pos2 = str.find_last_not_of(" \t");

    if (pos1 == std::string::npos && pos2 == std::string::npos)
        return "";
    else if (pos1 == std::string::npos)
        return str.substr(0, str.length() - pos2);
    else if (pos2 == std::string::npos)
        return str.substr(pos1);
    else
        return str.substr(pos1, pos2 - pos1 + 1);
}

bool
impl::to_bool(const std::string& str)
{
    bool b;

    atf_error_t err = atf_text_to_bool(str.c_str(), &b);
    if (atf_is_error(err))
        throw_atf_error(err);

    return b;
}

int64_t
impl::to_bytes(std::string str)
{
    if (str.empty())
        throw std::runtime_error("Empty value");

    const char unit = str[str.length() - 1];
    int64_t multiplier;
    switch (unit) {
    case 'k': case 'K': multiplier = 1 << 10; break;
    case 'm': case 'M': multiplier = 1 << 20; break;
    case 'g': case 'G': multiplier = 1 << 30; break;
    case 't': case 'T': multiplier = int64_t(1) << 40; break;
    default:
        if (!std::isdigit(unit))
            throw std::runtime_error(std::string("Unknown size unit '") + unit
                                     + "'");
        multiplier = 1;
    }
    if (multiplier != 1)
        str.erase(str.length() - 1);

    return to_type< int64_t >(str) * multiplier;
}
@


1.2
log
@PR/45619: jmmv: Allow atf tests to request a minimum amount of memory
@
text
@d4 1
a4 1
// Copyright (c) 2007, 2008, 2010 The NetBSD Foundation, Inc.
a35 1
#include <cstdlib>
d138 1
a138 1
impl::to_number(const std::string& str)
d140 20
a159 3
	int64_t num;
	::dehumanize_number(str.c_str(), &num);
	return num;
a160 1
    
@


1.1
log
@Initial revision
@
text
@d36 1
d137 9
@


1.1.1.1
log
@Import atf-0.11:

Experimental version released on October 20th, 2010.

* The ATF_CHECK* macros in atf-c++ were renamed to ATF_REQUIRE* to match
  their counterparts in atf-c.

* Clearly separated the modules in atf-c that are supposed to be public
  from those that are implementation details.  The header files for the
  internal modules are not installed any more.

* Made the atf-check tool private.  It is only required by atf-sh and being
  public has the danger of causing confusion.  Also, making it private
  simplifies the public API of atf.

* Changed atf-sh to enable per-command error checking (set -e) by default.
  This catches many cases in which a test case is broken but it is not
  reported as such because execution continues.

* Fixed the XSTL and CSS stylesheets to support expected failures.
@
text
@@


1.1.1.1.6.1
log
@sync with head
@
text
@d4 1
a4 1
// Copyright (c) 2007 The NetBSD Foundation, Inc.
a135 25

int64_t
impl::to_bytes(std::string str)
{
    if (str.empty())
        throw std::runtime_error("Empty value");

    const char unit = str[str.length() - 1];
    int64_t multiplier;
    switch (unit) {
    case 'k': case 'K': multiplier = 1 << 10; break;
    case 'm': case 'M': multiplier = 1 << 20; break;
    case 'g': case 'G': multiplier = 1 << 30; break;
    case 't': case 'T': multiplier = int64_t(1) << 40; break;
    default:
        if (!std::isdigit(unit))
            throw std::runtime_error(std::string("Unknown size unit '") + unit
                                     + "'");
        multiplier = 1;
    }
    if (multiplier != 1)
        str.erase(str.length() - 1);

    return to_type< int64_t >(str) * multiplier;
}
@


1.1.1.2
log
@Import atf 0.15: the major goal of this import is to reconcile any local
changes to the atf codebase with upstream code.  All local changes should
have been backported, with appropriate portability workarounds where
necessary.

This new release also includes other changes though, such as performance
improvements and bug fixes, and also a major new feature partially
implemented by pgoyette@@: the time to execute each test cases and test
program is now recorded and included in the output reports.

The import into NetBSD has been tested natively on amd64 and macppc, and
the full test suite has also been run through anita on amd64 and i386.
No regressions observed... but you never know.

From the NEWS file, the changes in this version are as follows:

Experimental version released on January 16th, 2012.

* Respect stdin in atf-check.  The previous release silenced stdin for any
  processes spawned by atf, not only test programs, which caused breakage
  in tests that pipe data through atf-check.

* Performance improvements to atf-sh.

* Enabled detection of unused parameters and variables in the code and
  fixed all warnings.

* Changed the behavior of "developer mode".  Compiler warnings are now
  enabled unconditionally regardless of whether we are in developer mode or
  not; developer mode is now only used to perform strict warning checks and
  to enable assertions.  Additionally, developer mode is now only
  automatically enabled when building from the repository, not for formal
  releases.

* Added new Autoconf M4 macros (ATF_ARG_WITH, ATF_CHECK_C and
  ATF_CHECK_CXX) to provide a consistent way of defining a --with-arg flag
  in configure scripts and detecting the presence of any of the ATF
  bindings.  Note that ATF_CHECK_SH was already introduced in 0.14, but it
  has now been modified to also honor --with-atf if instantiated.

* Added timing support to atf-run / atf-report.

* Added support for a 'require.memory' property, to specify the minimum
  amount of physical memory needed by the test case to yield valid results.

* PR bin/45690: Force an ISO-8859-1 encoding in the XML files generated by
  atf-report so that invalid data in the output of test cases does not
  mangle our report.
@
text
@d4 1
a4 1
// Copyright (c) 2007 The NetBSD Foundation, Inc.
a135 25

int64_t
impl::to_bytes(std::string str)
{
    if (str.empty())
        throw std::runtime_error("Empty value");

    const char unit = str[str.length() - 1];
    int64_t multiplier;
    switch (unit) {
    case 'k': case 'K': multiplier = 1 << 10; break;
    case 'm': case 'M': multiplier = 1 << 20; break;
    case 'g': case 'G': multiplier = 1 << 30; break;
    case 't': case 'T': multiplier = int64_t(1) << 40; break;
    default:
        if (!std::isdigit(unit))
            throw std::runtime_error(std::string("Unknown size unit '") + unit
                                     + "'");
        multiplier = 1;
    }
    if (multiplier != 1)
        str.erase(str.length() - 1);

    return to_type< int64_t >(str) * multiplier;
}
@

