This commit is contained in:
graduateDesign 2021-08-22 09:47:05 +08:00
parent 32269894a0
commit 867f93efad
12 changed files with 28 additions and 34 deletions

View File

@ -3,7 +3,6 @@
#include "SysObj.h"
#include <stdio.h>
extern DMEM_STATE DMEMS;
static uint8_t DMEMORY[DMEM_TOTAL_SIZE];
void checker_printMem(char *info, uint32_t size)
{
@ -21,28 +20,24 @@ void checker_printMemUsage(char *testName)
{
printf("---------------------------\r\n");
printf("Testing :%s\r\n", testName);
checker_printMem(" max = ", DMEMS.maxNum * DMEM_BLOCK_SIZE);
checker_printMem(" now = ", DMEMS.blk_num * DMEM_BLOCK_SIZE);
checker_printMem(" max = ", DMEMS.heapUsedMax);
checker_printMem(" now = ", DMEMS.heapUsed);
checker_printMem(" heap = ", DMEMS.heapUsed);
checker_printMem(" heap max = ", DMEMS.heapUsedMax);
checker_printMem(" heap max = ", DMEMS.heapUsedMax);
printf("---------------------------\r\n");
}
void checker_memInfo(void)
{
printf("---------------------------\r\n");
printf("Memory pool info:\r\n");
checker_printMem(" mem block size = ", DMEM_BLOCK_SIZE);
checker_printMem(" mem block num = ", DMEM_BLOCK_NUM);
checker_printMem(" mem pool size = ", sizeof(DMEMORY));
checker_printMem(" mem state size = ", sizeof(DMEM_STATE));
checker_printMem(" mem state size = ", (sizeof(DMEMORY) + sizeof(DMEM_STATE)));
printf("---------------------------\r\n");
}
void checker_assertMemFree()
{
if (0 == DMEMS.blk_num && 0 == DMEMS.heapUsed)
if (0 == DMEMS.heapUsed && 0 == DMEMS.heapUsed)
{
DMEMS.maxNum = 0;
DMEMS.heapUsedMax = 0;
DMEMS.heapUsedMax = 0;
return;
}

View File

@ -56,8 +56,8 @@ int32_t main()
char inputBuff[256] = {0};
/* run the script with check*/
obj_run(root, "led.on()");
printf("memory used max = %0.2f kB\r\n", DMEMS.maxNum*DMEM_BLOCK_SIZE/1024.0);
printf("memory used now = %0.2f kB\r\n", DMEMS.blk_num*DMEM_BLOCK_SIZE/1024.0);
printf("memory used max = %0.2f kB\r\n", DMEMS.heapUsedMax / 1024.0);
printf("memory used now = %0.2f kB\r\n", DMEMS.heapUsed / 1024.0);
while (1)
{
/* get user input */

View File

@ -53,8 +53,8 @@ int32_t main()
obj_run(root, "res = test.add(1, 2)");
int32_t res = obj_getInt(root, "res");
printf("the res of 'test.add(1, 2)' is %d \r\n", res);
printf("memory used max = %0.2f kB\r\n", DMEMS.maxNum*DMEM_BLOCK_SIZE/1024.0);
printf("memory used now = %0.2f kB\r\n", DMEMS.blk_num*DMEM_BLOCK_SIZE/1024.0);
printf("memory used max = %0.2f kB\r\n", DMEMS.heapUsedMax / 1024.0);
printf("memory used now = %0.2f kB\r\n", DMEMS.heapUsed / 1024.0);
while (1)
{
/* get user input */

View File

@ -51,8 +51,8 @@ int32_t main()
/* run the script with check*/
obj_run(root, "res = usart.send('hello world')");
printf("memory used max = %0.2f kB\r\n", DMEMS.maxNum * DMEM_BLOCK_SIZE / 1024.0);
printf("memory used now = %0.2f kB\r\n", DMEMS.blk_num * DMEM_BLOCK_SIZE / 1024.0);
printf("memory used max = %0.2f kB\r\n", DMEMS.heapUsedMax / 1024.0);
printf("memory used now = %0.2f kB\r\n", DMEMS.heapUsed / 1024.0);
while (1)
{
/* get user input */

View File

@ -10,13 +10,13 @@ void sendMethod(MimiObj *self, Args *args)
printf("[com1]: %s\r\n", data);
}
void setSpeedMethod(MimiObj *self , Args *args)
void setSpeedMethod(MimiObj *self, Args *args)
{
int32_t speed = args_getInt(args, "speed");
obj_setInt(self, "speed", speed);
}
void printSpeedMethod(MimiObj *self , Args *args)
void printSpeedMethod(MimiObj *self, Args *args)
{
int32_t speed = obj_getInt(self, "speed");
printf("%d\r\n", speed);
@ -107,8 +107,8 @@ int32_t main()
obj_run(root, "usart1.send('hello world')");
obj_run(root, "usart2.send('hello world')");
printf("memory used max = %0.2f kB\r\n", DMEMS.maxNum * DMEM_BLOCK_SIZE / 1024.0);
printf("memory used now = %0.2f kB\r\n", DMEMS.blk_num * DMEM_BLOCK_SIZE / 1024.0);
printf("memory used max = %0.2f kB\r\n", DMEMS.heapUsedMax / 1024.0);
printf("memory used now = %0.2f kB\r\n", DMEMS.heapUsed / 1024.0);
while (1)
{
/* get user input */

View File

@ -5,8 +5,8 @@
void obj_runWithInfo(MimiObj *self, char *cmd)
{
printf(">>> %s\r\n", cmd);
obj_run(self, cmd);
printf(">>> %s\r\n", cmd);
obj_run(self, cmd);
}
extern DMEM_STATE DMEMS;
@ -15,7 +15,7 @@ int main()
{
/* new root object */
MimiObj *root = newRootObj("root", New_SysObj);
obj_runWithInfo(root, "set('a',1)");
obj_runWithInfo(root, "print(a)");
obj_runWithInfo(root, "type('a')");
@ -25,15 +25,15 @@ int main()
obj_runWithInfo(root, "print(a)");
obj_runWithInfo(root, "type('a')");
obj_runWithInfo(root, "del('a')");
obj_runWithInfo(root, "set('a',1)");
obj_runWithInfo(root, "set('b',a)");
obj_runWithInfo(root, "print(b)");
obj_runWithInfo(root, "del('a')");
obj_runWithInfo(root, "del('b')");
printf("memory used max = %0.2f kB\r\n", DMEMS.maxNum*DMEM_BLOCK_SIZE/1024.0);
printf("memory used now = %0.2f kB\r\n", DMEMS.blk_num*DMEM_BLOCK_SIZE/1024.0);
printf("memory used max = %0.2f kB\r\n", DMEMS.heapUsedMax / 1024.0);
printf("memory used now = %0.2f kB\r\n", DMEMS.heapUsed / 1024.0);
/* user input buff */
char inputBuff[256] = {0};

@ -1 +1 @@
Subproject commit 93e465689c71214232d1739186706dc34c90a485
Subproject commit d71ad05c2f8cc0ce2060d9288b0dedd2b7d9925b

View File

@ -8,7 +8,7 @@ static int mem;
extern DMEM_STATE DMEMS;
TEST(args_test, test1)
{
mem = DMEMS.blk_num;
mem = DMEMS.heapUsed;
Args *args = New_args(NULL);
args_setInt(args, (char *)"a", 1);
int a = args_getInt(args, (char *)"a");
@ -173,6 +173,6 @@ TEST(args_test, test12)
extern DMEM_STATE DMEMS;
TEST(args_test, mem)
{
EXPECT_EQ(DMEMS.blk_num, mem);
EXPECT_EQ(DMEMS.heapUsed, mem);
EXPECT_EQ(DMEMS.heapUsed, 0);
}

View File

@ -6,7 +6,6 @@ typedef struct Class_dataTest dataTest_t;
struct Class_dataTest
{
/* attribute */
DMEM *mem;
void *context;
int32_t a;
int32_t b;

View File

@ -32,5 +32,5 @@ TEST(link_test, test1)
extern DMEM_STATE DMEMS;
TEST(link_test, mem)
{
EXPECT_EQ(DMEMS.blk_num, 0);
EXPECT_EQ(DMEMS.heapUsed, 0);
}

View File

@ -223,6 +223,6 @@ TEST(object_test, newObjectAndSetStr)
extern DMEM_STATE DMEMS;
TEST(object_test, mem)
{
EXPECT_EQ(DMEMS.blk_num, 0);
EXPECT_EQ(DMEMS.heapUsed, 0);
EXPECT_EQ(DMEMS.heapUsed, 0);
}

View File

@ -15,7 +15,7 @@ extern DMEM_STATE DMEMS;
static int mem;
TEST(strs, analizeDef)
{
mem = DMEMS.blk_num;
mem = DMEMS.heapUsed;
Args *buffs = New_args(NULL);
char currentClassName[] = "Compiler";
char line[] = " def analizeFile(pythonApiPath: str):";
@ -52,5 +52,5 @@ TEST(strs, analizeDef)
TEST(strs, mem)
{
EXPECT_EQ(DMEMS.blk_num, mem);
EXPECT_EQ(DMEMS.heapUsed, mem);
}