skia2/tests/TLSTest.cpp
humper@google.com 05af1afd42 eliminate all warnings in non-thirdparty code on mac
Most of these issues were due to functions whose definitions appear in header files; I changed those functions to be 'static inline' instead of just 'static' or 'inline', which kills the warning for such functions.

Other functions that were static or anonymous-namespaced but were unused in cpp files were probably called at some point but are no longer; someone who knows more than I do should probably scrub all the functions I either deleted or #if 0'ed out and make sure that the right thing is happening here.

Lots of unused variables removed, and one nasty const issue handled.

There remains a single warning in thirdparty/externals/cityhash/src/city.cc on line 146 related to a signed/unsigned mismatch.  I don't know if we have control over this library so I didn't fix this one, but perhaps someone could do something about that one.

BUG=

Review URL: https://codereview.appspot.com/7067044

git-svn-id: http://skia.googlecode.com/svn/trunk@7051 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-01-07 16:47:43 +00:00

84 lines
1.9 KiB
C++

/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Test.h"
#include "SkGraphics.h"
#include "SkPaint.h"
#include "SkTLS.h"
#include "SkThreadUtils.h"
static void thread_main(void*) {
SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024);
const char text[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
size_t len = strlen(text);
SkPaint paint;
for (int j = 0; j < 10; ++j) {
for (int i = 9; i <= 48; ++i) {
paint.setTextSize(SkIntToScalar(i));
paint.setAntiAlias(false);
paint.measureText(text, len);
paint.setAntiAlias(true);
paint.measureText(text, len);
}
}
}
static void test_threads(SkThread::entryPointProc proc) {
SkThread* threads[8];
int N = SK_ARRAY_COUNT(threads);
int i;
for (i = 0; i < N; ++i) {
threads[i] = new SkThread(proc);
}
for (i = 0; i < N; ++i) {
threads[i]->start();
}
for (i = 0; i < N; ++i) {
threads[i]->join();
}
for (i = 0; i < N; ++i) {
delete threads[i];
}
}
static int32_t gCounter;
static void* FakeCreateTLS() {
sk_atomic_inc(&gCounter);
return NULL;
}
static void FakeDeleteTLS(void* unused) {
sk_atomic_dec(&gCounter);
}
static void testTLSDestructor(void* unused) {
SkTLS::Get(FakeCreateTLS, FakeDeleteTLS);
}
static void TestTLS(skiatest::Reporter* reporter) {
// TODO: Disabled for now to work around
// http://code.google.com/p/skia/issues/detail?id=619
// ('flaky segfault in TLS test on Shuttle_Ubuntu12 buildbots')
if( false ) test_threads(&thread_main);
// Test to ensure that at thread destruction, TLS destructors
// have been called.
test_threads(&testTLSDestructor);
REPORTER_ASSERT(reporter, 0 == gCounter);
}
#include "TestClassDef.h"
DEFINE_TESTCLASS("TLS", TLSClass, TestTLS)