Fix class_linker_test.

ClassLinker::FindClass now requires the calling thread to be attached. Also
improve the error reporting in Thread::Attach.

Change-Id: I95bae22288902a8c19a99c14ad66f3dbcca4a0b6
diff --git a/src/class_linker_test.cc b/src/class_linker_test.cc
index a4775f3..d755e3e 100644
--- a/src/class_linker_test.cc
+++ b/src/class_linker_test.cc
@@ -41,6 +41,9 @@
 }
 
 TEST(ClassLinker, FindClass) {
+  ASSERT_TRUE(Thread::Init());
+  ASSERT_TRUE(Thread::Attach() != NULL);
+
   scoped_ptr<DexFile> dex(DexFile::OpenBase64(kMyClassDex));
   ASSERT_TRUE(dex != NULL);
 
diff --git a/src/thread.cc b/src/thread.cc
index 40a3f0e..a3899c7 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -95,8 +95,11 @@
 
   thread->state_ = kRunnable;
 
-  int result = pthread_setspecific(Thread::pthread_key_self_, thread);
-  CHECK_EQ(result, 0);
+  errno = pthread_setspecific(Thread::pthread_key_self_, thread);
+  if (errno != 0) {
+      PLOG(FATAL) << "pthread_setspecific failed";
+  }
+
   return thread;
 }