Change test makefile.

Change-Id: I27eef2cdb86b220dd03e9be79d5bef7f9303258b
diff --git a/mbtk/test/libmbtk_ftp/Makefile b/mbtk/test/libmbtk_ftp/Makefile
new file mode 100755
index 0000000..d520ad9
--- /dev/null
+++ b/mbtk/test/libmbtk_ftp/Makefile
@@ -0,0 +1,34 @@
+ROOT = $(shell pwd)/../../..
+include $(ROOT)/mbtk/Make.defines
+
+INC_DIR +=
+
+LIB_DIR +=
+
+LIBS += -lmbtk_lib -lmbtk_net -lmbtk_ftp
+
+CFLAGS += 
+
+DEFINE +=
+
+LOCAL_SRC_FILES = $(wildcard *.c) $(wildcard *.cpp)
+
+$(info LOCAL_SRC_FILES = $(LOCAL_SRC_FILES))
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(LOCAL_SRC_FILES)))
+BINS = $(patsubst %.o,%,$(OBJS))
+
+all: $(BINS)
+
+$(BINS):$(OBJS)
+	@echo "  BIN     $@"
+	$(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $@.o -o $(OUT_DIR)/bin/$@
+
+%.o:%.c
+	$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+%.o:%.cpp
+	$(CC) $(CFLAGS) $(INC_DIR) $(DEFINE) -c $< -o $@
+
+clean:
+	rm -f $(OBJS)
diff --git a/mbtk/test/libmbtk_ftp/mbtk_ftp_test.c b/mbtk/test/libmbtk_ftp/mbtk_ftp_test.c
new file mode 100755
index 0000000..481108d
--- /dev/null
+++ b/mbtk/test/libmbtk_ftp/mbtk_ftp_test.c
@@ -0,0 +1,144 @@
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "mbtk_type.h"
+#include "mbtk_ftp.h"
+#include "mbtk_log.h"
+#include "mbtk_str.h"
+
+static int ftp_cmd_process(mbtk_ftp_handle handle, const char *cmd)
+{
+    if(!strncasecmp(cmd, "download", 8)) {
+        // Download file: /data
+        uint32 len_count = 0;
+        uint32 len;
+        int download_time = 0;
+
+        uint32 file_size = mbtk_ftp_file_size(handle, "/Luo/Luo_up.txt");
+        if(file_size > 0)
+        {
+            printf("Will download file:/data[%d]\n", file_size);
+            // Start download
+            len = mbtk_ftp_download_start(handle, "/Luo/Luo_up.txt", "/tmp/ftp_data", NULL);
+            if(len > 0)
+            {
+                len_count += len;
+                download_time++;
+                printf("Download[time-%d] size:[%d / %d]\n", download_time, len_count, file_size);
+                while (len_count < file_size
+                       && download_time <= 10 // Try 10 times.
+                       && (len = mbtk_ftp_download_continue(handle)) > 0)
+                {
+                    len_count += len;
+                    download_time++;
+                    printf("Download[time-%d] size:[%d / %d]\n", download_time, len_count, file_size);
+                }
+
+                printf("Download complete - [%d / %d].\n",len_count, file_size);
+            }
+            else
+            {
+                printf("FTP download fail[%d / %d].\n",len_count, file_size);
+                return -1;
+            }
+        }else {
+            printf("File error.\n");
+            return -1;
+        }
+    }
+    else if(!strncasecmp(cmd, "upload", 6)) {
+        int len = 0;
+        len = mbtk_ftp_upload_start(handle, "/Luo/up_ftp3.txt", "/tmp/ftp_data", 0);
+        if( len != 0)
+        {
+            printf("FTP update fail\n");
+            return -1;
+        }
+        else
+        {
+            printf("FTP update success\n");
+        }
+    }
+    else if(!strncasecmp(cmd, "pwd", 3)) {
+        char path[50] = {0};
+        mbtk_ftp_error_enum err = mbtk_ftp_pwd(handle, path);
+        if(FTP_ERR_SUCCESS != err) {
+            printf("mbtk_ftp_pwd() fail:%d\n", err);
+            return -1;
+        }
+
+        printf("PWD : %s\n", path);
+    } else if(!strncasecmp(cmd, "cd ", 3)) {
+        char path[50] = {0};
+        memcpy(path, cmd + 3, strlen(cmd) - 3);
+        mbtk_ftp_error_enum err = mbtk_ftp_cd(handle, path);
+        if(FTP_ERR_SUCCESS != err) {
+            printf("mbtk_ftp_cd() fail:%d\n", err);
+            return -1;
+        }
+
+        printf("cd %s\n", path);
+    } else if(!strncasecmp(cmd, "ls", 2)) {
+        mbtk_ftp_file_info_s list_head;
+        mbtk_ftp_error_enum err = mbtk_ftp_dir_ls(handle, &list_head);
+        if(FTP_ERR_SUCCESS != err) {
+            printf("mbtk_ftp_dir_ls() fail:%d\n", err);
+            return -1;
+        }
+
+        mbtk_ftp_file_info_s *f_ptr = list_head.next;
+        while(f_ptr && !str_empty(f_ptr->name)) {
+            printf("%s, %s, %d\n", f_ptr->name, f_ptr->is_file ? "F" : "D", f_ptr->size);
+            f_ptr = f_ptr->next;
+        }
+    } else {
+        printf("Unknow CMD.\n");
+        return -1;
+    }
+
+    return 0;
+}
+
+int main(int argc, char *argv[])
+{
+    mbtk_ftp_handle handle = mbtk_ftp_init("58.246.1.50", 6521, FTP_AUTH_TYPE_NON, false, false);
+    if(handle < 0) {
+        printf("mbtk_ftp_init() fail.\n");
+        return -1;
+    }
+
+    mbtk_ftp_error_enum err = mbtk_ftp_login(handle, " FTP_TST", "FTPTST_0320");
+    if(err != FTP_ERR_SUCCESS) {
+        printf("mbtk_ftp_login() fail:%d\n", err);
+        goto ftp_exit;
+    }
+
+    printf("Login success.\nCMD:");
+
+    char cmd[50];
+    while(1) {
+        memset(cmd, 0, 50);
+        gets(cmd);
+        if(!strcasecmp(cmd, "q")) {
+            break;
+        } else {
+            ftp_cmd_process(handle, cmd);
+        }
+
+        printf("CMD:");
+    }
+
+    printf("FTP test success.\n");
+ftp_quit:
+    mbtk_ftp_quit(handle);
+ftp_exit:
+    mbtk_ftp_deinit(handle);
+    printf("FTP test complete.\n");
+    return 0;
+
+}
+