aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-13 19:51:39 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-13 19:51:39 +0000
commit741ba7d4c1150ab8cb05b37234908834eff0f487 (patch)
treed624fc2faac317a4e6b197fbaa3a167a34542868
parent33c682c935ebb92c8265bfe0f4f997a6bce13bee (diff)
downloadpaludis-741ba7d4c1150ab8cb05b37234908834eff0f487.tar.gz
paludis-741ba7d4c1150ab8cb05b37234908834eff0f487.tar.xz
QA framework
-rw-r--r--paludis/qa/Makefile.am.m44
-rw-r--r--paludis/qa/check.cc32
-rw-r--r--paludis/qa/check.hh51
-rw-r--r--paludis/qa/check_result.cc30
-rw-r--r--paludis/qa/check_result.hh89
-rw-r--r--paludis/qa/check_result_TEST.cc45
-rw-r--r--paludis/qa/file_check.cc33
-rw-r--r--paludis/qa/file_check.hh77
-rw-r--r--paludis/qa/file_permissions_check.cc60
-rw-r--r--paludis/qa/file_permissions_check.hh46
-rw-r--r--paludis/qa/file_permissions_check_TEST.cc90
-rwxr-xr-xpaludis/qa/file_permissions_check_TEST_cleanup.sh11
-rwxr-xr-xpaludis/qa/file_permissions_check_TEST_setup.sh14
-rw-r--r--paludis/qa/files.m46
-rw-r--r--paludis/qa/message.cc24
-rw-r--r--paludis/qa/message.hh64
-rw-r--r--paludis/qa/message_TEST.cc42
17 files changed, 715 insertions, 3 deletions
diff --git a/paludis/qa/Makefile.am.m4 b/paludis/qa/Makefile.am.m4
index 0f4b37c..1a85a13 100644
--- a/paludis/qa/Makefile.am.m4
+++ b/paludis/qa/Makefile.am.m4
@@ -8,8 +8,8 @@ define(`testlist', `')dnl
define(`testscriptlist', `')dnl
define(`addtest', `define(`testlist', testlist `$1_TEST')dnl
$1_TEST_SOURCES = $1_TEST.cc
-$1_TEST_LDADD = test_extras.o $(top_builddir)/test/libtest.a \
- $(top_builddir)/test/libpaludis.a libpaludisqa.a
+$1_TEST_LDADD = $(top_builddir)/paludis/test_extras.o $(top_builddir)/test/libtest.a \
+ libpaludisqa.a $(top_builddir)/paludis/libpaludis.a
$1_TEST_CXXFLAGS = -I$(top_srcdir)
')dnl
define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl
diff --git a/paludis/qa/check.cc b/paludis/qa/check.cc
new file mode 100644
index 0000000..45af1a2
--- /dev/null
+++ b/paludis/qa/check.cc
@@ -0,0 +1,32 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "check.hh"
+
+using namespace paludis;
+using namespace paludis::qa;
+
+Check::Check()
+{
+}
+
+Check::~Check()
+{
+}
+
diff --git a/paludis/qa/check.hh b/paludis/qa/check.hh
new file mode 100644
index 0000000..61b868b
--- /dev/null
+++ b/paludis/qa/check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_QA_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_CHECK_HH 1
+
+#include <paludis/instantiation_policy.hh>
+
+/** \file
+ * Declarations for the paludis::qa::Check class.
+ *
+ * \ingroup QA
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * Base class for a QA check.
+ *
+ * \ingroup QA
+ */
+ class Check :
+ private InstantiationPolicy<Check, instantiation_method::NonCopyableTag>
+ {
+ protected:
+ Check();
+
+ virtual ~Check();
+ };
+ }
+}
+
+#endif
diff --git a/paludis/qa/check_result.cc b/paludis/qa/check_result.cc
new file mode 100644
index 0000000..13763a8
--- /dev/null
+++ b/paludis/qa/check_result.cc
@@ -0,0 +1,30 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "check_result.hh"
+
+using namespace paludis;
+using namespace paludis::qa;
+
+CheckResult::CheckResult(const FSEntry & f, const std::string & r) :
+ _item(stringify(f)),
+ _rule(stringify(r))
+{
+}
+
diff --git a/paludis/qa/check_result.hh b/paludis/qa/check_result.hh
new file mode 100644
index 0000000..d5a02a3
--- /dev/null
+++ b/paludis/qa/check_result.hh
@@ -0,0 +1,89 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_QA_CHECK_RESULT_HH
+#define PALUDIS_GUARD_PALUDIS_QA_CHECK_RESULT_HH 1
+
+#include <paludis/fs_entry.hh>
+#include <paludis/qa/message.hh>
+#include <list>
+
+/** \file
+ * Declarations for the CheckResult class.
+ *
+ * \ingroup QA
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * The result of a QA check.
+ *
+ * \ingroup QA
+ */
+ class CheckResult
+ {
+ private:
+ std::list<Message> _messages;
+
+ const std::string _item;
+ const std::string _rule;
+
+ public:
+ CheckResult(const FSEntry &, const std::string &);
+
+ bool empty() const
+ {
+ return _messages.empty();
+ }
+
+ CheckResult & operator<< (const Message & m)
+ {
+ _messages.push_back(m);
+ return *this;
+ }
+
+ typedef std::list<Message>::const_iterator Iterator;
+
+ Iterator begin() const
+ {
+ return _messages.begin();
+ }
+
+ Iterator end() const
+ {
+ return _messages.end();
+ }
+
+ const std::string & item() const
+ {
+ return _item;
+ }
+
+ const std::string & rule() const
+ {
+ return _rule;
+ }
+ };
+ }
+}
+
+#endif
diff --git a/paludis/qa/check_result_TEST.cc b/paludis/qa/check_result_TEST.cc
new file mode 100644
index 0000000..e023f48
--- /dev/null
+++ b/paludis/qa/check_result_TEST.cc
@@ -0,0 +1,45 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "check_result.hh"
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+using namespace test;
+
+namespace test_cases
+{
+ struct CheckResultTest : TestCase
+ {
+ CheckResultTest() : TestCase("check result") { }
+
+ void run()
+ {
+ CheckResult r(FSEntry("/"), "blah");
+ TEST_CHECK_EQUAL(r.item(), "/");
+ TEST_CHECK_EQUAL(r.rule(), "blah");
+ TEST_CHECK(r.empty());
+ r << Message(qal_info, "moo");
+ TEST_CHECK(! r.empty());
+ }
+ } test_check_result;
+}
+
diff --git a/paludis/qa/file_check.cc b/paludis/qa/file_check.cc
new file mode 100644
index 0000000..18405bc
--- /dev/null
+++ b/paludis/qa/file_check.cc
@@ -0,0 +1,33 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "file_check.hh"
+
+using namespace paludis;
+using namespace paludis::qa;
+
+FileCheck::FileCheck()
+{
+}
+
+NoSuchFileCheckTypeError::NoSuchFileCheckTypeError(const std::string & s) throw () :
+ Exception("No such file check type: '" + s + "'")
+{
+}
+
diff --git a/paludis/qa/file_check.hh b/paludis/qa/file_check.hh
new file mode 100644
index 0000000..a2faaa9
--- /dev/null
+++ b/paludis/qa/file_check.hh
@@ -0,0 +1,77 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_QA_FILE_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_FILE_CHECK_HH 1
+
+#include <paludis/exception.hh>
+#include <paludis/fs_entry.hh>
+#include <paludis/counted_ptr.hh>
+#include <paludis/virtual_constructor.hh>
+#include <paludis/qa/check.hh>
+#include <paludis/qa/check_result.hh>
+
+/** \file
+ * Declarations for the FIleCheck class.
+ *
+ * \ingroup QA
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * A QA check that operates upon a file.
+ *
+ * \ingroup QA
+ */
+ class FileCheck :
+ public Check,
+ public InternalCounted<FileCheck>
+ {
+ protected:
+ FileCheck();
+
+ public:
+ virtual CheckResult operator() (const FSEntry &) const = 0;
+ };
+
+ class NoSuchFileCheckTypeError :
+ public Exception
+ {
+ public:
+ NoSuchFileCheckTypeError(const std::string &) throw ();
+ };
+
+ template <typename T_>
+ FileCheck::Pointer
+ make_file_check()
+ {
+ return FileCheck::Pointer(new T_);
+ }
+
+ typedef VirtualConstructor<
+ std::string,
+ FileCheck::Pointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchFileCheckTypeError> > FileCheckMaker;
+ }
+}
+
+#endif
diff --git a/paludis/qa/file_permissions_check.cc b/paludis/qa/file_permissions_check.cc
new file mode 100644
index 0000000..4f48d78
--- /dev/null
+++ b/paludis/qa/file_permissions_check.cc
@@ -0,0 +1,60 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "file_permissions_check.hh"
+
+using namespace paludis;
+using namespace paludis::qa;
+
+FilePermissionsCheck::FilePermissionsCheck()
+{
+}
+
+CheckResult
+FilePermissionsCheck::operator() (const FSEntry & f) const
+{
+ CheckResult result(f, identifier());
+
+ if (f.is_directory())
+ {
+ if (! f.has_permission(fs_ug_owner, fs_perm_read))
+ result << Message(qal_minor, "Directory owner does not have read permission");
+
+ if (! f.has_permission(fs_ug_owner, fs_perm_execute))
+ result << Message(qal_minor, "Directory owner does not have execute permission");
+ }
+ else
+ {
+ if (! f.has_permission(fs_ug_owner, fs_perm_read))
+ result << Message(qal_minor, "File owner does not have read permission");
+
+ if (f.has_permission(fs_ug_owner, fs_perm_execute))
+ result << Message(qal_minor, "File owner has execute permission");
+ }
+
+ return result;
+}
+
+const std::string &
+FilePermissionsCheck::identifier()
+{
+ static const std::string id("file permissions");
+ return id;
+}
+
diff --git a/paludis/qa/file_permissions_check.hh b/paludis/qa/file_permissions_check.hh
new file mode 100644
index 0000000..14bf511
--- /dev/null
+++ b/paludis/qa/file_permissions_check.hh
@@ -0,0 +1,46 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_QA_FILE_PERMISSIONS_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_FILE_PERMISSIONS_CHECK_HH 1
+
+#include <paludis/qa/file_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ class FilePermissionsCheck :
+ public FileCheck
+ {
+ public:
+ FilePermissionsCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+ };
+
+ static const FileCheckMaker::RegisterMaker register_file_permissions_check(
+ FilePermissionsCheck::identifier(), &make_file_check<FilePermissionsCheck>);
+ }
+}
+
+#endif
diff --git a/paludis/qa/file_permissions_check_TEST.cc b/paludis/qa/file_permissions_check_TEST.cc
new file mode 100644
index 0000000..85e0f6c
--- /dev/null
+++ b/paludis/qa/file_permissions_check_TEST.cc
@@ -0,0 +1,90 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "file_permissions_check.hh"
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+using namespace test;
+
+namespace test_cases
+{
+ struct FilePermissionsCheckFileTest : TestCase
+ {
+ FilePermissionsCheckFileTest() : TestCase("file permissions file") { }
+
+ void run()
+ {
+ FSEntry e("file_permissions_check_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "ok_file");
+ TEST_CHECK(f1.exists());
+ CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker(
+ FilePermissionsCheck::identifier()))())(f1));
+ TEST_CHECK(r1.empty());
+
+ FSEntry f2(e / "no_read_file");
+ TEST_CHECK(f2.exists());
+ CheckResult r2((*(*FileCheckMaker::get_instance()->find_maker(
+ FilePermissionsCheck::identifier()))())(f2));
+ TEST_CHECK(! r2.empty());
+
+ FSEntry f3(e / "exec_file");
+ TEST_CHECK(f3.exists());
+ CheckResult r3((*(*FileCheckMaker::get_instance()->find_maker(
+ FilePermissionsCheck::identifier()))())(f3));
+ TEST_CHECK(! r3.empty());
+ }
+ } test_file_permissions_check_file;
+
+ struct FilePermissionsCheckDirTest : TestCase
+ {
+ FilePermissionsCheckDirTest() : TestCase("file permissions dir") { }
+
+ void run()
+ {
+ FSEntry e("file_permissions_check_TEST_dir");
+ TEST_CHECK(e.exists());
+ TEST_CHECK(e.is_directory());
+
+ FSEntry f1(e / "ok_dir");
+ TEST_CHECK(f1.exists());
+ CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker(
+ FilePermissionsCheck::identifier()))())(f1));
+ TEST_CHECK(r1.empty());
+
+ FSEntry f2(e / "no_read_dir");
+ TEST_CHECK(f2.exists());
+ CheckResult r2((*(*FileCheckMaker::get_instance()->find_maker(
+ FilePermissionsCheck::identifier()))())(f2));
+ TEST_CHECK(! r2.empty());
+
+ FSEntry f3(e / "no_exec_dir");
+ TEST_CHECK(f3.exists());
+ CheckResult r3((*(*FileCheckMaker::get_instance()->find_maker(
+ FilePermissionsCheck::identifier()))())(f3));
+ TEST_CHECK(! r3.empty());
+ }
+ } test_file_permissions_check_dir;
+}
+
diff --git a/paludis/qa/file_permissions_check_TEST_cleanup.sh b/paludis/qa/file_permissions_check_TEST_cleanup.sh
new file mode 100755
index 0000000..08bd40e
--- /dev/null
+++ b/paludis/qa/file_permissions_check_TEST_cleanup.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d file_permissions_check_TEST_dir ] ; then
+ chmod -R +rX file_permissions_check_TEST_dir
+ rm -fr file_permissions_check_TEST_dir
+else
+ true
+fi
+
+
diff --git a/paludis/qa/file_permissions_check_TEST_setup.sh b/paludis/qa/file_permissions_check_TEST_setup.sh
new file mode 100755
index 0000000..34178f5
--- /dev/null
+++ b/paludis/qa/file_permissions_check_TEST_setup.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir file_permissions_check_TEST_dir || exit 2
+cd file_permissions_check_TEST_dir || exit 3
+
+touch ok_file no_read_file exec_file || exit 4
+chmod -r no_read_file || exit 5
+chmod +x exec_file || exit 6
+
+mkdir ok_dir no_read_dir no_exec_dir || exit 7
+chmod -r no_read_dir || exit 8
+chmod -x no_exec_dir || exit 9
+
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index 084641f..e96fd3e 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -8,5 +8,9 @@ dnl the base filename with no extension; later parameters can be `hh', `cc',
dnl `test', `impl', `testscript'. Note that there isn't much error checking done
dnl on this file at present...
+add(`check', `hh', `cc')
+add(`check_result', `hh', `cc', `test')
add(`environment', `hh', `cc')
-
+add(`file_check', `hh', `cc')
+add(`file_permissions_check', `hh', `cc', `test', `testscript')
+add(`message', `hh', `cc', `test')
diff --git a/paludis/qa/message.cc b/paludis/qa/message.cc
new file mode 100644
index 0000000..cd959dc
--- /dev/null
+++ b/paludis/qa/message.cc
@@ -0,0 +1,24 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "message.hh"
+
+using namespace paludis;
+using namespace paludis::qa;
+
diff --git a/paludis/qa/message.hh b/paludis/qa/message.hh
new file mode 100644
index 0000000..e5490d6
--- /dev/null
+++ b/paludis/qa/message.hh
@@ -0,0 +1,64 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_QA_MESSAGE_HH
+#define PALUDIS_GUARD_PALUDIS_QA_MESSAGE_HH 1
+
+#include <paludis/smart_record.hh>
+#include <string>
+
+/** \file
+ * Declarations for the Message class.
+ *
+ * \ingroup QA
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ enum QALevel
+ {
+ qal_info,
+ qal_maybe,
+ qal_minor,
+ qal_major,
+ qal_fatal
+ };
+
+ enum MessageKeys
+ {
+ mk_level,
+ mk_msg,
+ last_mk
+ };
+
+ struct MessageTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<MessageKeys, last_mk>,
+ SmartRecordKey<mk_level, QALevel>,
+ SmartRecordKey<mk_msg, std::string>
+ {
+ };
+
+ typedef MakeSmartRecord<MessageTag>::Type Message;
+ }
+}
+
+#endif
diff --git a/paludis/qa/message_TEST.cc b/paludis/qa/message_TEST.cc
new file mode 100644
index 0000000..9c05593
--- /dev/null
+++ b/paludis/qa/message_TEST.cc
@@ -0,0 +1,42 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "message.hh"
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+using namespace test;
+
+namespace test_cases
+{
+ struct MessageTest : TestCase
+ {
+ MessageTest() : TestCase("message") { }
+
+ void run()
+ {
+ Message m(qal_minor, "Test");
+ TEST_CHECK_EQUAL(m.get<mk_level>(), qal_minor);
+ TEST_CHECK_EQUAL(m.get<mk_msg>(), "Test");
+ }
+ } test_message;
+}
+