提交 7e7f0fb5 编写于 作者: xpxyr's avatar xpxyr 提交者: geniusgogo

add test/test10.c

上级 7d88b753
......@@ -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('#'))]
......
#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)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册