add test/test10.c
This commit is contained in:
parent
7d88b753d6
commit
7e7f0fb5f5
|
@ -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还没有移植的。请不要使用。
|
||||
|
|
|
@ -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
Load Diff
|
@ -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)
|
Loading…
Reference in New Issue