buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #include "class_linker.h" |
| 4 | #include "common_test.h" |
| 5 | #include "dex_file.h" |
| 6 | #include "heap.h" |
| 7 | #include "object.h" |
| 8 | #include "scoped_ptr.h" |
| 9 | |
| 10 | #include <stdint.h> |
| 11 | #include <stdio.h> |
| 12 | #include "gtest/gtest.h" |
| 13 | |
| 14 | namespace art { |
| 15 | |
| 16 | class CompilerTest : public CommonTest { |
| 17 | }; |
| 18 | |
| 19 | #if defined(__arm__) |
| 20 | TEST_F(CompilerTest, BasicCodegen) { |
| 21 | scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kFibonacciDex, |
| 22 | "kFibonacciDex")); |
| 23 | PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get()); |
| 24 | |
| 25 | Thread::Current()->SetClassLoaderOverride(class_loader); |
| 26 | |
| 27 | JNIEnv* env = Thread::Current()->GetJniEnv(); |
| 28 | |
| 29 | jclass c = env->FindClass("Fibonacci"); |
| 30 | ASSERT_TRUE(c != NULL); |
| 31 | |
| 32 | jmethodID m = env->GetStaticMethodID(c, "fibonacci", "(I)I"); |
| 33 | ASSERT_TRUE(m != NULL); |
| 34 | |
| 35 | jint result = env->CallStaticIntMethod(c, m, 10); |
| 36 | LOG(INFO) << "Fibonacci[10] is " << result; |
| 37 | |
| 38 | ASSERT_EQ(55, result); |
| 39 | } |
| 40 | #endif |
| 41 | |
| 42 | } // namespace art |