Browse Source

add test/test10.c

geniusgogo 11 years ago
parent
commit
7e7f0fb5f5

+ 4 - 3
components/external/sqlite/README

@@ -5,7 +5,7 @@
 
 测试方法:
 1.   
-    在rtconfig.h中定义一下宏
+    在rtconfig.h中定义一下宏,并打开newlib组件
     /*
     * SQLite compile macro
     */
@@ -18,13 +18,14 @@
     #define SQLITE_TEMP_STORE 1
     #define SQLITE_THREADSAFE 1
     #define HAVE_READLINE 0 
-    #define NDEBUG 
+    #define NDEBUG
+    #define SQLITE_TEST
     #define _HAVE_SQLITE_CONFIG_H 
     #define BUILD_sqlite
     #define SQLITE_OS_OTHER 1 
     #define SQLITE_OS_RTT 1
 2.
-    在test目录下找一个测试样例来加入工程进行测试.
+    用test目录下的test10.c来进行测试.
     推荐用mini2440bsp,因为板子的ram较大。
 
 注意shell.c还没有移植的。请不要使用。

+ 1 - 0
components/external/sqlite/SConscript

@@ -5,6 +5,7 @@ from building import *
 cwd = GetCurrentDir()
 src = Split("""
 sqlite3.c
+test/test10.c
 """)
 CPPPATH = [cwd, str(Dir('#'))]
 

File diff suppressed because it is too large
+ 154 - 153
components/external/sqlite/sqlite3.c


+ 37 - 0
components/external/sqlite/test/test10.c

@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <sqlite3.h>
+#include "finsh.h"
+
+static int callback(void *NotUsed, int argc, char **argv, char **azColName){
+  int i;
+  for(i=0; i<argc; i++){
+    rt_kprintf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
+  }
+  rt_kprintf("\n");
+  return 0;
+}
+
+int test10_main(int argc, char **argv){
+  sqlite3 *db;
+  char *zErrMsg = 0;
+  int rc;
+
+  if( argc!=3 ){
+    rt_kprintf("Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
+    return(1);
+  }
+  rc = sqlite3_open(argv[1], &db);
+  if( rc ){
+    rt_kprintf("Can't open database: %s\n", sqlite3_errmsg(db));
+    sqlite3_close(db);
+    return(1);
+  }
+  rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
+  if( rc!=SQLITE_OK ){
+    rt_kprintf("SQL error: %s\n", zErrMsg);
+    sqlite3_free(zErrMsg);
+  }
+  sqlite3_close(db);
+  return 0;
+}
+FINSH_FUNCTION_EXPORT(test10_main, sqlite test)

Some files were not shown because too many files changed in this diff