Esempio n. 1
0
void test_move()
{
	assert(NULL != sexp_parse("(move/from16 v12,v1234)", &sexp));
	/*assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0, NULL));
	assert(inst.opcode == DVM_MOVE);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].payload.uint16 == 12);
	assert(inst.operands[1].payload.uint16 == 1234);
	assert(inst.operands[0].header.info.size == 0);*/
	sexp_free(sexp);
	
	assert(NULL != sexp_parse("(move-wide/from16 v12,v1234)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_MOVE);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].payload.uint16 == 12);
	assert(inst.operands[1].payload.uint16 == 1234);
	assert(inst.operands[0].header.info.size == 1);
	assert(inst.operands[1].header.info.size == 1);
	sexp_free(sexp);
	
	assert(NULL != sexp_parse("(move v12,v1234)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_MOVE);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].payload.uint16 == 12);
	assert(inst.operands[1].payload.uint16 == 1234);
	assert(inst.operands[0].header.info.size == 0);
	assert(inst.operands[1].header.info.size == 0);
	sexp_free(sexp);

	assert(NULL != sexp_parse("(move-result/wide v1234)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_MOVE);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].payload.uint16 == 1234);
	assert(inst.operands[0].header.info.size == 1);
	assert(inst.operands[1].header.info.is_result);
	sexp_free(sexp);

	assert(NULL != sexp_parse("(move-result-object v1234)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_MOVE);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].payload.uint16 == 1234);
	assert(inst.operands[0].header.info.size == 0);
	assert(inst.operands[0].header.info.type = DVM_OPERAND_TYPE_OBJECT);
	assert(inst.operands[1].header.info.type = DVM_OPERAND_TYPE_OBJECT);
	assert(inst.operands[1].header.info.is_result);
	sexp_free(sexp);
}
Esempio n. 2
0
void test_packed()
{
	assert(NULL != sexp_parse(
		   "(packed-switch v123, 456,\n"
		   "  l456,     ;case456\n"
		   "  l457,     ;case457\n"
		   "  l458,     ;case458\n"
		   "  ldefault  ;default\n"
		   ")", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(DVM_SWITCH == inst.opcode);
	assert(3 == inst.num_operands);
	assert(123 == inst.operands[0].payload.uint16);
	assert(0 == inst.operands[0].header.flags);
	assert(1 == inst.operands[1].header.info.is_const);
	assert(456 == inst.operands[1].payload.uint16);
	assert(inst.operands[1].header.info.type == DVM_OPERAND_TYPE_INT);
	assert(inst.operands[2].header.info.type == DVM_OPERAND_TYPE_LABELVECTOR);
	assert(inst.operands[2].header.info.is_const == 1);
	assert(inst.operands[2].payload.branches != NULL);
	vector_t* v = inst.operands[2].payload.branches;
	assert(0 == *(int*)vector_get(v, 0));
	assert(1 == *(int*)vector_get(v, 1));
	assert(2 == *(int*)vector_get(v, 2));
	assert(3 == *(int*)vector_get(v, 3));
	assert(0 == dalvik_label_get_label_id(stringpool_query("l456")));
	assert(1 == dalvik_label_get_label_id(stringpool_query("l457")));
	assert(2 == dalvik_label_get_label_id(stringpool_query("l458")));
	assert(3 == dalvik_label_get_label_id(stringpool_query("ldefault")));
	sexp_free(sexp);
	dalvik_instruction_free(&inst);
}
Esempio n. 3
0
int main()
{
	adam_init();
	
	sexpression_t* svoid;
	assert(NULL != sexp_parse("void", &svoid));
	tvoid = dalvik_type_from_sexp(svoid);
	sexp_free(svoid);
	assert(NULL != tvoid);
	/* load package */
	dalvik_loader_from_directory("test/cases/block_analyzer");
	
	
	/* run test cases */
	case1();

	case2();

	case3();

	dalvik_type_free(tvoid);
	/* finalize */
	adam_finalize();
	return 0;
}
Esempio n. 4
0
void test_arrayops()
{
#if DALVIK_ARRAY_SUPPORT
	assert(NULL != sexp_parse("(aput v1 v2 v3)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_ARRAY);
	assert(inst.flags = DVM_FLAG_ARRAY_PUT);
	assert(inst.num_operands == 3);
	assert(inst.operands[0].header.flags == 0);
	assert(inst.operands[0].payload.uint16 == 1);
	assert(inst.operands[1].header.info.type == DVM_OPERAND_TYPE_OBJECT);
	assert(inst.operands[1].payload.uint16 == 2);
	assert(inst.operands[2].header.info.type == DVM_OPERAND_TYPE_INT);
	assert(inst.operands[2].payload.uint16 == 3);
	sexp_free(sexp);
	dalvik_instruction_free(&inst);

	assert(NULL != sexp_parse("(aput-object v1 v2 v3)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_ARRAY);
	assert(inst.flags = DVM_FLAG_ARRAY_PUT);
	assert(inst.num_operands == 3);
	assert(inst.operands[0].header.info.type == DVM_OPERAND_TYPE_OBJECT);
	assert(inst.operands[0].payload.uint16 == 1);
	assert(inst.operands[1].header.info.type == DVM_OPERAND_TYPE_OBJECT);
	assert(inst.operands[1].payload.uint16 == 2);
	assert(inst.operands[2].header.info.type == DVM_OPERAND_TYPE_INT);
	assert(inst.operands[2].payload.uint16 == 3);
	sexp_free(sexp);
	dalvik_instruction_free(&inst);
	
	assert(NULL != sexp_parse("(aget-object v1 v2 v3)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_ARRAY);
	assert(inst.flags = DVM_FLAG_ARRAY_GET);
	assert(inst.num_operands == 3);
	assert(inst.operands[0].header.info.type == DVM_OPERAND_TYPE_OBJECT);
	assert(inst.operands[0].payload.uint16 == 1);
	assert(inst.operands[1].header.info.type == DVM_OPERAND_TYPE_OBJECT);
	assert(inst.operands[1].payload.uint16 == 2);
	assert(inst.operands[2].header.info.type == DVM_OPERAND_TYPE_INT);
	assert(inst.operands[2].payload.uint16 == 3);
	sexp_free(sexp);
	dalvik_instruction_free(&inst);
#endif
}
Esempio n. 5
0
void test_return()
{
	assert(NULL != sexp_parse("(return-object v1234)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_RETURN);
	assert(inst.num_operands == 1);
	assert(inst.operands[0].payload.uint16 == 1234);
	assert(inst.operands[0].header.info.size == 0);
	assert(inst.operands[0].header.info.type = DVM_OPERAND_TYPE_OBJECT);
	sexp_free(sexp);
	
	assert(NULL != sexp_parse("(return-void)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_RETURN);
	assert(inst.num_operands == 1);
	assert(inst.operands[0].header.info.type = DVM_OPERAND_TYPE_VOID);
	sexp_free(sexp);
}
Esempio n. 6
0
void test_instanceops()
{
	assert(NULL != sexp_parse("(iput v1 v2 myclass.Property1 [array [object java.lang.String]])", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_INSTANCE);
	assert(inst.flags = DVM_FLAG_INSTANCE_PUT);
	assert(inst.num_operands == 5);
	sexp_free(sexp);
	dalvik_instruction_free(&inst);
}
Esempio n. 7
0
void test_monitor()
{
	assert(NULL != sexp_parse("(monitor-enter v123)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_MONITOR);
	assert(inst.num_operands == 1);
	assert(inst.operands[0].header.info.type == 0);
	assert(inst.operands[0].payload.uint16 == 123);
	assert(inst.operands[0].header.info.is_const == 0);
	assert(inst.flags == DVM_FLAG_MONITOR_ENT);
	sexp_free(sexp);
	
	assert(NULL != sexp_parse("(monitor-exit v123)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_MONITOR);
	assert(inst.num_operands == 1);
	assert(inst.operands[0].header.info.type == 0);
	assert(inst.operands[0].payload.uint16 == 123);
	assert(inst.operands[0].header.info.is_const == 0);
	assert(inst.flags == DVM_FLAG_MONITOR_EXT);
	sexp_free(sexp);
}
Esempio n. 8
0
int main() {
    char* sexp_str =
        "(@\"main.c\":20:50 struct\n"
        "  (union)\n"
        "  23\n"
        "  \"a string with a backslash (\\\\) and a quote (\\\"). woo\" \n"
        "  (@\"main.c\":21:52 struct (struct) 43))\n"
        "(struct \"something else\")\n";
    struct sexp* s = sexp_parse(sexp_str);
    printf("Original:\n%s\n", sexp_str);
    printf("Parsed and dumped: \n");
    sexp_dump(s);
    sexp_free(s);
    return 0;
}
Esempio n. 9
0
/**
 * free all levels of a stack
 */
void
destroy_stack (faststack_t * s)
{
  stack_lvl_t *sl;

  /* return if stack is null.  no error condition - just return. */
  if (s == NULL)
    return;

  /* start at the bottom */
  sl = s->bottom;

  /* if bottom is null, no levels to free. just free stack itself then. */
  if (sl == NULL) {
    sexp_free(s, sizeof(faststack_t));
    return;
  }

  /* go up to the top of the allocated stack */
  while (sl->above != NULL)
    sl = sl->above;

  /* until we get to the bottom (where below is null), free the data
     at each level and the level itself. */
  while (sl->below != NULL)
    {
      sl = sl->below;
      sexp_free (sl->above, sizeof(stack_lvl_t));
    }

  /* free the bottom level */
  sexp_free (sl, sizeof(stack_lvl_t));

  /* free the stack wrapper itself. */
  sexp_free (s, sizeof(faststack_t));
}
Esempio n. 10
0
int main(int argc, char** argv){
  if (argc <= 1){
    fprintf(stderr, "usage: %s [run|dump] <program>, where <program> is a sexp-compiled C file\n", argv[0]);
    exit(1);
  }
  char* file = argv[argc-1];
  FILE* prog = fopen(file, "r");
  if (!prog){
    perror("Couldn't open program");
  }
  char progbuf[MAXFILE];
  fread(progbuf, MAXFILE, 1, prog);
  if (!feof(prog)){
    fprintf(stderr, "Couldn't read all of %s", file);
    exit(1);
  }
  struct sexp* sexpcode = sexp_parse(progbuf);
  if (!sexpcode){
    fprintf(stderr, "Couldn't parse s-expressions in %s", file);
    exit(1);
  }
  struct program* program = compile(sexpcode);
  sexp_free(sexpcode);

  if (!program){
    fprintf(stderr, "Couldn't compile\n");
    exit(1);
  }

  if (argc == 3){
    if (!strcmp(argv[1], "run")){
      run(program);
    }else if (!strcmp(argv[1], "dump")){
      program_dump(program);
    }
  }else{ 
    while(1){
      get_command();
      if(parse_command(program)){
        break;
      }
    }
  }
  return 0;
}
Esempio n. 11
0
void test_sparse()
{
	assert(NULL != sexp_parse(
		   "(sparse-switch v4 \n"
		   "    (9 sp1) \n"
		   "    (10 sp2) \n"
		   "    (13 sp3) \n"
		   "    (65535 sp4)\n"
		   "    (default sp5))", 
		   &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_SWITCH);
	assert(inst.flags == DVM_FLAG_SWITCH_SPARSE);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].header.flags == 0);
	assert(inst.operands[0].payload.uint16 = 4);
	assert(inst.operands[1].header.info.is_const == 1);
	assert(inst.operands[1].header.info.type == DVM_OPERAND_TYPE_SPARSE);
	assert(inst.operands[1].payload.sparse != NULL);
	vector_t* v = inst.operands[1].payload.branches;
	assert(4 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 0))->labelid);
	assert(5 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 1))->labelid);
	assert(6 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 2))->labelid);
	assert(7 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 3))->labelid);
	assert(8 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 4))->labelid);

	assert(9 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 0))->cond);
	assert(10 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 1))->cond);
	assert(13 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 2))->cond);
	assert(65535 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 3))->cond);
	assert(0 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 4))->cond);
	
	assert(0 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 0))->is_default);
	assert(0 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 1))->is_default);
	assert(0 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 2))->is_default);
	assert(0 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 3))->is_default);
	assert(1 ==((dalvik_sparse_switch_branch_t *)vector_get(v, 4))->is_default);

	assert(5 == vector_size(v));

	sexp_free(sexp);
	dalvik_instruction_free(&inst);
}
Esempio n. 12
0
void test_const()
{
	assert(NULL != sexp_parse("(const/high16 v123,1)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_CONST);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].header.flags == 0);
	assert(inst.operands[0].header.info.type == 0);
	assert(inst.operands[0].payload.uint16 == 123);
	assert(inst.operands[1].header.info.is_const == 1);
	assert(inst.operands[1].payload.uint32 == 0x10000);
	sexp_free(sexp);


	assert(NULL != sexp_parse("(const v123,1235)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_CONST);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].header.flags == 0);
	assert(inst.operands[0].header.info.type == 0);
	assert(inst.operands[0].payload.uint16 == 123);
	assert(inst.operands[1].header.info.is_const == 1);
	assert(inst.operands[1].payload.uint32 == 1235);
	sexp_free(sexp);
	
	assert(NULL != sexp_parse("(const/4 v123,1235)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_CONST);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].header.flags == 0);
	assert(inst.operands[0].header.info.type == 0);
	assert(inst.operands[0].payload.uint16 == 123);
	assert(inst.operands[1].header.info.is_const == 1);
	assert(inst.operands[1].payload.uint32 == 1235);
	sexp_free(sexp);
	
	assert(NULL != sexp_parse("(const/16 v123,1235)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_CONST);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].header.flags == 0);
	assert(inst.operands[0].header.info.type == 0);
	assert(inst.operands[0].payload.uint16 == 123);
	assert(inst.operands[1].header.info.is_const == 1);
	assert(inst.operands[1].payload.uint32 == 1235);
	sexp_free(sexp);
	
	assert(NULL != sexp_parse("(const-wide v123,123456789)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_CONST);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].header.info.size == 1);
	assert(inst.operands[0].header.info.type == 0);
	assert(inst.operands[0].payload.uint16 == 123);
	assert(inst.operands[1].header.info.is_const == 1);
	assert(inst.operands[1].payload.uint64 == 123456789);
	sexp_free(sexp);
	
	assert(NULL != sexp_parse("(const-wide v123,123456789)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_CONST);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].header.info.size == 1);
	assert(inst.operands[0].header.info.type == 0);
	assert(inst.operands[0].payload.uint16 == 123);
	assert(inst.operands[1].header.info.is_const == 1);
	assert(inst.operands[1].payload.uint64 == 123456789);
	sexp_free(sexp);
	
	assert(NULL != sexp_parse("(const-wide/high16 v123,1)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_CONST);
	assert(inst.num_operands == 2);
	assert(inst.operands[0].header.info.size == 1);
	assert(inst.operands[0].header.info.type == 0);
	assert(inst.operands[0].payload.uint16 == 123);
	assert(inst.operands[1].header.info.is_const == 1);
	assert(inst.operands[1].payload.uint64 == 0x0001000000000000ull);
	sexp_free(sexp);
	
	assert(NULL != sexp_parse("(const-string v123,\"this is a test case for const-string\")", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_CONST);
	assert(inst.num_operands == 2);
	assert(inst.operands[1].header.info.type == DVM_OPERAND_TYPE_STRING);
	assert(inst.operands[1].payload.string == stringpool_query("this is a test case for const-string"));
	assert(inst.operands[1].header.info.is_const == 1);
	sexp_free(sexp);
	
	assert(NULL != sexp_parse("(const-class v123,this/is/a/test/class)", &sexp));
	assert(0 == dalvik_instruction_from_sexp(sexp, &inst, 0));
	assert(inst.opcode == DVM_CONST);
	assert(inst.num_operands == 2);
	assert(inst.operands[1].header.info.type == DVM_OPERAND_TYPE_CLASS);
	assert(inst.operands[1].payload.string == stringpool_query("this/is/a/test/class"));
	assert(inst.operands[1].header.info.is_const == 1);
	sexp_free(sexp);
}
Esempio n. 13
0
int main()
{
	adam_init();

	/* Runnability test */
	assert(dalvik_loader_from_directory("test/data/AndroidAntlr") >= 0);
	sexpression_t* sexp;
	sexp_parse("[object java/lang/String]", &sexp);
	dalvik_type_t *type = dalvik_type_from_sexp(sexp);
	sexp_free(sexp);
	const char* classname = stringpool_query("antlr/ANTLRParser");
	const char* methodname = stringpool_query("treeParserSpec");
	dalvik_type_t* arglist[] = {NULL ,NULL};
	arglist[0] = type;
	
	sexpression_t* svoid;
	assert(NULL != sexp_parse("void", &svoid));
	dalvik_type_t* tvoid = dalvik_type_from_sexp(svoid);
	sexp_free(svoid);
	
	dalvik_block_t* block = dalvik_block_from_method(classname, methodname, (const dalvik_type_t**)arglist, tvoid);
	dalvik_type_free(type);
	assert(NULL != block);

	/* setup function test */
	assert(dalvik_loader_from_directory("test/cases/dalvik_block") >= 0);
	arglist[0] = NULL;
	classname = stringpool_query("TestClass");
	
	/* Case 1 */
	methodname = stringpool_query("case1");
	block = dalvik_block_from_method(classname, methodname, (const dalvik_type_t**)arglist, tvoid);
	const dalvik_method_t* method = dalvik_memberdict_get_method(classname, methodname, (const dalvik_type_t**)arglist, tvoid);
	assert(NULL != method);
	assert(NULL != block);
	assert(block->begin == method->entry);
	assert(block->end == method->entry + 3);
	assert(block->nbranches == 1);
	assert(block->branches[0].conditional == 0);
	assert(DALVIK_BLOCK_BRANCH_UNCOND_TYPE_IS_JUMP(block->branches[0]));
	dalvik_block_t* retblk = block->branches[0].block;
	assert(NULL != retblk);
	assert(1 == retblk->nbranches);
	assert(DALVIK_BLOCK_BRANCH_UNCOND_TYPE_IS_RETURN(retblk->branches[0]));

	/* Case 2 */
	methodname = stringpool_query("case2");
	block = dalvik_block_from_method(classname, methodname, (const dalvik_type_t**)arglist, tvoid);
	method = dalvik_memberdict_get_method(classname, methodname, (const dalvik_type_t**)arglist, tvoid);
	assert(NULL != block);
	assert(NULL != method);
	/* verify block0 */
	assert(block->begin == method->entry);
	assert(block->end   == method->entry + 2);
	assert(block->nbranches == 2);
	assert(block->branches[0].disabled == 0);
	assert(block->branches[0].linked == 1);
	assert(block->branches[0].conditional == 1);
	assert(block->branches[0].eq == 1);
	assert(block->branches[0].lt == 0);
	assert(block->branches[0].gt == 0);
	assert(block->branches[0].left_inst == 0);
	assert(block->branches[0].left->header.flags == 0);
	assert(block->branches[0].left->payload.uint16 == 1);
	assert(block->branches[0].right->header.flags == 0);
	assert(block->branches[0].right->payload.uint16 == 2);
	assert(block->branches[0].block != NULL);
	assert(block->branches[1].disabled == 0);
	assert(block->branches[1].linked == 1);
	assert(block->branches[1].conditional == 0);
	assert(block->branches[1].block != NULL);
	/* verify block2 */
	dalvik_block_t* block2 = block->branches[0].block;
	assert(block2->begin == method->entry + 5);
	assert(block2->end == method->entry + 6);
	assert(block2->nbranches == 1);
	assert(block2->branches[0].disabled == 0);
	assert(block2->branches[0].linked == 1);
	assert(block2->branches[0].conditional == 0);
	assert(block2->branches[0].block != NULL);
	/* verify block1 */
	dalvik_block_t* block1 = block->branches[1].block;
	assert(block1->begin == method->entry + 3);
	assert(block1->end == method->entry + 4);
	assert(block1->nbranches == 1);
	assert(block1->branches[0].disabled == 0);
	assert(block1->branches[0].linked == 1);
	assert(block1->branches[0].conditional == 0);
	assert(block1->branches[0].block != NULL);
	assert(block1->branches[0].block == block2->branches[0].block);
	/* verify block3 */
	dalvik_block_t* block3 = block1->branches[0].block;
	assert(block3->begin == method->entry + 6);
	assert(block3->end == method->entry + 6);
	assert(block3->nbranches == 1);
	assert(DALVIK_BLOCK_BRANCH_UNCOND_TYPE_IS_RETURN(block3->branches[0]));
	assert(block3->branches[0].block == NULL);
	assert(block3->branches[0].left->payload.uint16 == 1);
	assert(block3->branches[0].block == NULL);

	/* Case 3 */
	methodname = stringpool_query("case3");
	block = dalvik_block_from_method(classname, methodname, (const dalvik_type_t**)arglist, tvoid);
	method = dalvik_memberdict_get_method(classname, methodname, (const dalvik_type_t**)arglist, tvoid);
	assert(NULL != block);
	assert(NULL != method);
	/* verify block 1 */
	assert(block->begin == method->entry + 0);
	assert(block->end == method->entry + 2);
	assert(block->nbranches == 1);
	assert(block->branches[0].linked == 1);
	assert(block->branches[0].disabled == 0);
	assert(block->branches[0].conditional == 0);
	assert(block->branches[0].block != NULL);
	/* verify block 3*/
	block3 = block->branches[0].block;
	assert(block3->begin == method->entry + 6);
	assert(block3->end == method->entry + 7);
	assert(block3->nbranches == 1);
	assert(block3->branches[0].linked == 1);
	assert(block3->branches[0].disabled == 0);
	assert(DALVIK_BLOCK_BRANCH_UNCOND_TYPE_IS_JUMP(block3->branches[0]));

	/*verify block 4 */
	dalvik_block_t* block4 = block3->branches[0].block;
	assert(block4->begin == method->entry + 7);
	assert(block4->end == method->entry + 7);
	assert(block4->nbranches == 1);
	assert(DALVIK_BLOCK_BRANCH_UNCOND_TYPE_IS_RETURN(block4->branches[0]));
	assert(block4->branches[0].left->payload.uint16 == 9);
	assert(block4->branches[0].block == NULL);

	/* Case 4 */
	methodname = stringpool_query("case4");
	block = dalvik_block_from_method(classname, methodname, (const dalvik_type_t**) arglist, tvoid);
	method = dalvik_memberdict_get_method(classname, methodname, (const dalvik_type_t**) arglist, tvoid);
	assert(NULL != block);
	assert(NULL != method);
	/* verify block 1 */
	assert(block->begin == method->entry + 0);
	assert(block->end == method->entry + 1);
	assert(block->nbranches == 1);
	assert(block->branches[0].linked == 1);
	assert(block->branches[0].disabled == 0);
	assert(block->branches[0].conditional == 0);
	assert(block->branches[0].block != NULL);
	/* verify block 2 */
	block2 = block->branches[0].block;
	assert(block2->begin == method->entry + 1);
	assert(block2->end == method->entry + 2);
	assert(block2->nbranches == 1);
	assert(block2->branches[0].linked == 1);
	assert(block2->branches[0].conditional == 0);
	assert(block2->branches[0].disabled == 0);
	assert(block2->branches[0].block != NULL);
	/* verify block3 */
	block3 = block2->branches[0].block;
	assert(block3->begin == method->entry + 2);
	assert(block3->end == method->entry + 3);
	assert(block3->nbranches == 1);
	assert(block3->branches[0].linked == 1);
	assert(block3->branches[0].conditional == 0);
	assert(block3->branches[0].disabled == 0);
	
	block4 = block3->branches[0].block;
	assert(NULL != block4);
	assert(DALVIK_BLOCK_BRANCH_UNCOND_TYPE_IS_RETURN(block4->branches[0]));
	assert(block4->branches[0].block == NULL);

	/* Case 5 */
	methodname = stringpool_query("case5");
	block = dalvik_block_from_method(classname, methodname, (const dalvik_type_t**) arglist, tvoid);
	method = dalvik_memberdict_get_method(classname, methodname, (const dalvik_type_t**) arglist, tvoid);
	assert(NULL != block);
	assert(NULL != method);

	adam_finalize();
	return 0;
}