| 1 |
/* |
| 2 |
* FCML - Free Code Manipulation Library. |
| 3 |
* Copyright (C) 2010-2020 Slawomir Wojtasiak |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <stdio.h> |
| 21 |
#include <stdlib.h> |
| 22 |
|
| 23 |
#include <fcml_stf.h> |
| 24 |
|
| 25 |
/* FCML.*/ |
| 26 |
#include <fcml_intel_dialect.h> |
| 27 |
#include <fcml_gas_dialect.h> |
| 28 |
#include <fcml_assembler.h> |
| 29 |
#include <fcml_disassembler.h> |
| 30 |
#include <fcml_renderer.h> |
| 31 |
|
| 32 |
/* Tests.*/ |
| 33 |
#include "error_handling_t.h" |
| 34 |
#include "instructions_a_t.h" |
| 35 |
#include "instructions_b_t.h" |
| 36 |
#include "instructions_c_t.h" |
| 37 |
#include "instructions_d_t.h" |
| 38 |
#include "instructions_e_t.h" |
| 39 |
#include "instructions_f_t.h" |
| 40 |
#include "instructions_g_t.h" |
| 41 |
#include "instructions_h_t.h" |
| 42 |
#include "instructions_i_t.h" |
| 43 |
#include "instructions_j_t.h" |
| 44 |
#include "instructions_l_t.h" |
| 45 |
#include "instructions_k_t.h" |
| 46 |
#include "instructions_m_t.h" |
| 47 |
#include "instructions_n_t.h" |
| 48 |
#include "instructions_o_t.h" |
| 49 |
#include "instructions_p_t.h" |
| 50 |
#include "instructions_r_t.h" |
| 51 |
#include "instructions_s_t.h" |
| 52 |
#include "instructions_t_t.h" |
| 53 |
#include "instructions_u_t.h" |
| 54 |
#include "instructions_v_t.h" |
| 55 |
#include "instructions_w_t.h" |
| 56 |
#include "instructions_x_t.h" |
| 57 |
#include "hints_t.h" |
| 58 |
#include "prefixes_t.h" |
| 59 |
#include "segment_reg_t.h" |
| 60 |
#include "chooser_t.h" |
| 61 |
#include "render_t.h" |
| 62 |
#include "disassembler_t.h" |
| 63 |
#include "assembler_t.h" |
| 64 |
#include "general_usage_t.h" |
| 65 |
|
| 66 |
#include "instructions_base_t.h" |
| 67 |
|
| 68 |
fcml_stf_test_suite *fcml_arr_suites[] = { |
| 69 |
&fcml_si_render, |
| 70 |
&fctl_si_instructions_a, |
| 71 |
&fctl_si_instructions_b, |
| 72 |
&fctl_si_instructions_c, |
| 73 |
&fctl_si_instructions_d, |
| 74 |
&fctl_si_instructions_e, |
| 75 |
&fctl_si_instructions_f, |
| 76 |
&fctl_si_instructions_g, |
| 77 |
&fctl_si_instructions_h, |
| 78 |
&fctl_si_instructions_i, |
| 79 |
&fctl_si_instructions_j, |
| 80 |
&fctl_si_instructions_l, |
| 81 |
&fctl_si_instructions_k, |
| 82 |
&fctl_si_instructions_m, |
| 83 |
&fctl_si_instructions_n, |
| 84 |
&fctl_si_instructions_o, |
| 85 |
&fctl_si_instructions_p, |
| 86 |
&fctl_si_instructions_r, |
| 87 |
&fctl_si_instructions_s, |
| 88 |
&fctl_si_instructions_t, |
| 89 |
&fctl_si_instructions_u, |
| 90 |
&fctl_si_instructions_v, |
| 91 |
&fctl_si_instructions_w, |
| 92 |
&fctl_si_instructions_x, |
| 93 |
&fcml_si_error_handling, |
| 94 |
&fcml_si_hints, |
| 95 |
&fcml_si_chooser, |
| 96 |
&fcml_si_prefixes, |
| 97 |
&fcml_si_segment_reg, |
| 98 |
&fcml_si_disassembler, |
| 99 |
&fcml_si_assembler, |
| 100 |
&fcml_si_general_usage, |
| 101 |
FCML_STF_NULL_SUITE |
| 102 |
}; |
| 103 |
|
| 104 |
int main(int argc, char **argv) { |
| 105 |
|
| 106 |
fcml_ceh_error error; |
| 107 |
fcml_bool result = FCML_TRUE; |
| 108 |
|
| 109 |
error = fcml_fn_dialect_init_intel( FCML_INTEL_DIALECT_CF_DEFAULT, &dialect_intel ); |
| 110 |
if( error ) { |
| 111 |
exit(1); |
| 112 |
} |
| 113 |
|
| 114 |
error = fcml_fn_dialect_init_gas( FCML_GAS_DIALECT_CF_DEFAULT, &dialect_gas ); |
| 115 |
if( error ) { |
| 116 |
fcml_fn_dialect_free( dialect_intel ); |
| 117 |
exit(1); |
| 118 |
} |
| 119 |
|
| 120 |
assembler_intel = NULL; |
| 121 |
assembler_gas = NULL; |
| 122 |
|
| 123 |
error = fcml_fn_assembler_init( dialect_intel, &assembler_intel ); |
| 124 |
if( error ) { |
| 125 |
fcml_fn_dialect_free( dialect_intel ); |
| 126 |
fcml_fn_dialect_free( dialect_gas ); |
| 127 |
printf("Cannot initialize INTEL assembler.\n"); |
| 128 |
exit(1); |
| 129 |
} |
| 130 |
|
| 131 |
error = fcml_fn_assembler_init( dialect_gas, &assembler_gas ); |
| 132 |
if( error ) { |
| 133 |
fcml_fn_assembler_free( assembler_intel ); |
| 134 |
fcml_fn_dialect_free( dialect_intel ); |
| 135 |
fcml_fn_dialect_free( dialect_gas ); |
| 136 |
printf("Cannot initialize AT&T assembler.\n"); |
| 137 |
exit(1); |
| 138 |
} |
| 139 |
|
| 140 |
error = fcml_fn_disassembler_init( dialect_intel, &disassembler_intel ); |
| 141 |
if( error ) { |
| 142 |
/* Error.*/ |
| 143 |
fcml_fn_assembler_free( assembler_intel ); |
| 144 |
fcml_fn_assembler_free( assembler_gas ); |
| 145 |
fcml_fn_dialect_free( dialect_intel ); |
| 146 |
fcml_fn_dialect_free( dialect_gas ); |
| 147 |
printf( "Cannot allocate INTEL disassembler.\n" ); |
| 148 |
exit(1); |
| 149 |
} |
| 150 |
|
| 151 |
error = fcml_fn_disassembler_init( dialect_gas, &disassembler_gas ); |
| 152 |
if( error ) { |
| 153 |
/* Error.*/ |
| 154 |
fcml_fn_disassembler_free( disassembler_intel ); |
| 155 |
fcml_fn_assembler_free( assembler_intel ); |
| 156 |
fcml_fn_assembler_free( assembler_gas ); |
| 157 |
fcml_fn_dialect_free( dialect_intel ); |
| 158 |
fcml_fn_dialect_free( dialect_gas ); |
| 159 |
printf( "Cannot allocate AT&T disassembler.\n" ); |
| 160 |
exit(1); |
| 161 |
} |
| 162 |
|
| 163 |
/* Run tests. */ |
| 164 |
result = fcml_stf_run_tests( "Public API tests", fcml_arr_suites ); |
| 165 |
|
| 166 |
fcml_fn_disassembler_free( disassembler_intel ); |
| 167 |
fcml_fn_disassembler_free( disassembler_gas ); |
| 168 |
fcml_fn_assembler_free( assembler_intel ); |
| 169 |
fcml_fn_assembler_free( assembler_gas ); |
| 170 |
fcml_fn_dialect_free( dialect_intel ); |
| 171 |
fcml_fn_dialect_free( dialect_gas ); |
| 172 |
|
| 173 |
exit( result ? 0 : 1 ); |
| 174 |
} |