diff --git a/python26.spec b/python26.spec
index 7d24a08..fb717cf 100644
--- a/python26.spec
+++ b/python26.spec
@@ -64,6 +64,13 @@
 
 %global with_system_expat 0
 
+# ppc in Koji doesn't seem to be able to locate valgrind-devel, for some reason
+%ifarch ppc
+%global with_valgrind 0
+%else
+%global with_valgrind 1
+%endif
+
 # Redefine __os_install_post, removing the invocation of brp-python-bytecompile
 # (this is normally defined in /usr/lib/rpm/redhat/macros)
 #
@@ -92,7 +99,7 @@
 Summary: An interpreted, interactive, object-oriented programming language
 Name: %{python}
 Version: 2.6.5
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: Python
 Group: Development/Languages
 Provides: python-abi = %{pybasever}
@@ -141,6 +148,9 @@ Source4: systemtap-example.stp
 # be byte-compiled using python2.6
 Source5: macros.python26
 
+# A bash script for more easily running the regression test suite.
+# Taken from the "py3k" branch from upstream:
+Source6: runtests.sh
 
 # Modules/Setup.dist is ultimately used by the "makesetup" script to construct
 # the Makefile and config.c
@@ -366,8 +376,11 @@ BuildRequires: db4-devel
 BuildRequires: libffi-devel
 
 
-# Valgrind headers are in core valgrind subpackage on EL5
-BuildRequires: valgrind
+# Valgrind headers were in core valgrind subpackage on EL5, but were moved to
+# a valgrind-devel subpackage in 3.5.0-1.el5
+%if 0%{with_valgrind}
+BuildRequires: valgrind-devel
+%endif
 
 
 %if 0%{?with_systemtap}
@@ -490,6 +503,10 @@ code that uses more than just unittest and/or test_support.py.
 cp -a %{SOURCE4} .
 %endif # with_systemtap
 
+# Provide the runtests.sh from py3k branch for use by the "check" stage:
+cp -a %{SOURCE6} .
+chmod +x runtests.sh
+
 # Ensure that we're using the system copy of various libraries, rather than
 # copies shipped by upstream in the tarball:
 #   Remove embedded copy of expat:
@@ -532,7 +549,9 @@ rm -r Modules/zlib || exit 1
 %patch17 -p1 -b .distutils-rpath
 
 %patch51 -p1 -b .brprpm
+%if 0%{with_valgrind}
 %patch52 -p0 -b .valgrind
+%endif
 %if 0%{?with_systemtap}
 %patch55 -p1 -b .systemtap
 %endif
@@ -599,7 +618,11 @@ exit 0
   --with-dtrace \
   --with-tapset-install-dir=%{tapsetdir} \
 %endif
-  --with-valgrind
+%if 0%{with_valgrind}
+  --with-valgrind \
+%endif
+%{nil}
+
 
 make OPT="$CFLAGS" %{?_smp_mflags}
 LD_LIBRARY_PATH="$topdir" $topdir/python Tools/scripts/pathfix.py -i "%{_bindir}/env python%{pybasever}" .
@@ -822,6 +845,105 @@ sed \
 mkdir -p %{buildroot}%{_sysconfdir}/rpm
 install -p -m 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/rpm/macros.python26
 
+%check
+# Run the upstream test suite
+LD_LIBRARY_PATH=$(pwd) ./runtests.sh
+
+# Note that we're running the tests using the version of the code in the builddir,
+# not in the buildroot; runtests.sh looks for "./python"
+
+# The harness only emits the names of the test scripts it ran, along with a
+# summary of the form:
+#   2 BAD
+# 313 GOOD
+#  22 SKIPPED
+# 337 total
+# As a byproduct it writes files "GOOD", "BAD", "SKIPPED", listing names of
+# files (e.g. "test_imp") along with a subdirectory OUT containing files of the
+# form $TEST.out
+# Each such logfile starts with a line indicating the name of the test
+
+# Output the logs from failing tests, so that they are captured in the rpmbuild
+# log:
+cat BAD
+for TESTNAME in $(cat BAD); do
+  cat OUT/$TESTNAME.out ; 
+done
+
+# Known/expected failures:
+# Seen on all architectures:
+#   + cat OUT/test_distutils.out
+#   test_distutils
+#   /usr/bin/ld: cannot find -lpython2.6
+#   collect2: ld returned 1 exit status
+#   test test_distutils failed -- Traceback (most recent call last):
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/distutils/tests/test_build_ext.py", line 261, in test_get_outputs
+#       cmd.run()
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/distutils/command/build_ext.py", line 340, in run
+#       self.build_extensions()
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/distutils/command/build_ext.py", line 449, in build_extensions
+#       self.build_extension(ext)
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/distutils/command/build_ext.py", line 531, in build_extension
+#       target_lang=language)
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/distutils/ccompiler.py", line 769, in link_shared_object
+#       extra_preargs, extra_postargs, build_temp, target_lang)
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/distutils/unixccompiler.py", line 268, in link
+#       raise LinkError, msg
+#   LinkError: command 'gcc' failed with exit status 1
+#
+# Seen on x86_64 only:
+#   + cat OUT/test_dl.out
+#   test test_dl crashed -- <type 'exceptions.SystemError'>: module dl requires sizeof(int) == sizeof(long) == sizeof(char*)
+#
+# Seen on all architectures:
+#   + cat OUT/test_file.out
+#   test test_file failed -- Traceback (most recent call last):
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/test/test_file.py", line 201, in testStdin
+#       self.assertRaises(IOError, sys.stdin.seek, -1)
+#   AssertionError: IOError not raised
+#
+# Seen on all architectures:
+#   + cat OUT/test_socket.out
+#   test test_socket failed -- Traceback (most recent call last):
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/test/test_socket.py", line 482, in testSockName
+#       my_ip_addr = socket.gethostbyname(socket.gethostname())
+#   gaierror: [Errno -3] Temporary failure in name resolution
+#
+# Seen on all architectures:
+#   + cat OUT/test_subprocess.out
+#   test test_subprocess failed -- Traceback (most recent call last):
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/test/test_subprocess.py", line 500, in test_leaking_fds_on_error
+#       stderr=subprocess.PIPE)
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/subprocess.py", line 633, in __init__
+#       errread, errwrite)
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/subprocess.py", line 1139, in _execute_child
+#       raise child_exception
+#   OSError: [Errno 13] Permission denied
+#
+# Seen on all architectures:
+#   + cat OUT/test_urllib2.out
+#   test test_urllib2 failed -- Traceback (most recent call last):
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/test/test_urllib2.py", line 712, in test_file
+#       h.file_open, Request(url))
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/unittest.py", line 336, in failUnlessRaises
+#       callableObj(*args, **kwargs)
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/urllib2.py", line 1257, in file_open
+#       return self.open_local_file(req)
+#     File "/builddir/build/BUILD/Python-2.6.5/Lib/urllib2.py", line 1289, in open_local_file
+#       (not port and socket.gethostbyname(host) in self.get_names()):
+#   gaierror: [Errno -3] Temporary failure in name resolution
+#
+
+# Exit with an error if an unexpected error occurs:
+cat BAD \
+    | grep -v test_distutils \
+    | grep -v test_dl \
+    | grep -v test_file \
+    | grep -v test_socket \
+    | grep -v test_subprocess \
+    | grep -v test_urllib2 \
+    &&  echo "Unexpected selftest failure: " && exit 1
+
 %clean
 rm -fr %{buildroot}
 
@@ -985,7 +1107,6 @@ rm -fr %{buildroot}
 %{_bindir}/python-config
 %endif
 %{_bindir}/python%{pybasever}-config
-%{pylibdir}/config/*
 %{_libdir}/libpython%{pybasever}.so
 
 %files tools
@@ -1039,6 +1160,12 @@ rm -fr %{buildroot}
 # payload file would be unpackaged)
 
 %changelog
+* Mon Mar 29 2010 David Malcolm <dmalcolm@redhat.com> - 2.6.5-2
+- add a %%check section, running the regression test suite and failing the
+build if an unexpected error occurs
+- fix stray doublelisting of config directory wildcard in devel subpackage
+- valgrind grew a -devel subpackage in el5 ; disable for now on ppc
+
 * Mon Mar 22 2010 David Malcolm <dmalcolm@redhat.com> - 2.6.5-1
 - update to 2.6.5: http://www.python.org/download/releases/2.6.5/
 - update patch 110 so that it still applies in the face of upstream r78380
diff --git a/runtests.sh b/runtests.sh
new file mode 100755
index 0000000..2d3cfc8
--- /dev/null
+++ b/runtests.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+HELP="Usage: ./runtests.py [-h] [-x] [flags] [tests]
+
+Runs each unit test independently, with output directed to a file in
+OUT/<test>.out.  If no tests are given, all tests are run; otherwise,
+only the specified tests are run, unless -x is also given, in which
+case all tests *except* those given are run.
+
+Standard output shows the name of the tests run, with 'BAD' or
+'SKIPPED' added if the test didn't produce a positive result.  Also,
+three files are created, named 'BAD', 'GOOD' and 'SKIPPED', to which
+are written the names of the tests categorized by result.
+
+Flags (arguments starting with '-') are passed transparently to
+regrtest.py, except for -x, which is processed here."
+
+# Choose the Python binary.
+case `uname` in
+Darwin) PYTHON=./python.exe;;
+CYGWIN*) PYTHON=./python.exe;;
+*)      PYTHON=./python;;
+esac
+
+PYTHON="$PYTHON -bb"
+
+# Unset PYTHONPATH, just to be sure.
+unset PYTHONPATH
+
+# Create the output directory if necessary.
+mkdir -p OUT
+
+# Empty the summary files.
+>GOOD
+>BAD
+>SKIPPED
+
+# Process flags (transparently pass these on to regrtest.py)
+FLAGS=""
+EXCEPT=""
+while :
+do
+    case $1 in
+    -h|--h|-help|--help) echo "$HELP"; exit;;
+    --) FLAGS="$FLAGS $1"; shift; break;;
+    -x) EXCEPT="$1"; shift;;
+    -*) FLAGS="$FLAGS $1"; shift;;
+    *)  break;;
+    esac
+done
+
+# Compute the list of tests to run.
+case "$#$EXCEPT" in
+0) 
+    TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//')`
+    ;;
+*-x)
+    PAT="^(`echo $@ | sed 's/\.py//' | sed 's/ /|/'`)$"
+    TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//' | egrep -v "$PAT")`
+    ;;
+*)
+    TESTS="$@"
+    ;;
+esac
+
+# Run the tests.
+for T in $TESTS
+do
+    echo -n $T
+    if   case $T in
+         *curses*)
+	     echo
+	     $PYTHON -E Lib/test/regrtest.py $FLAGS $T 2>OUT/$T.out
+	     ;;
+         *)  $PYTHON -E Lib/test/regrtest.py $FLAGS $T >OUT/$T.out 2>&1;;
+         esac
+    then
+        if grep -q "1 test skipped:" OUT/$T.out
+        then
+            echo " SKIPPED"
+            echo $T >>SKIPPED
+        else
+            echo
+            echo $T >>GOOD
+        fi
+    else
+        echo " BAD"
+        echo $T >>BAD
+    fi
+done
+
+# Summarize results
+wc -l BAD GOOD SKIPPED
