4
%% Copyright Ericsson AB 2005-2010. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
21
-module(test_compile_options).
23
-include_lib("test_server/include/test_server.hrl").
26
-export([wrong_path/1,comp/2,path/1,ticket_6143/1,noobj/1,
27
record_name_prefix/1,verbose/1]).
31
Pid=spawn(?MODULE,comp,[self(),Config]),
40
comp(Parent,Config) ->
41
DataDir = ?config(data_dir,Config),
42
OutDir = ?config(priv_dir,Config),
43
%%?line true = code:add_patha(?config(priv_dir,Config)),
44
io:format("DataDir: ~p~n",[DataDir]),
45
?line Err=asn1ct:compile(DataDir++"NoImport",[{i,OutDir},{i,filename:join([DataDir,"subdir"])},{outdir,OutDir}]),
46
io:format("compiling process terminated with value: ~p~n",[Err]),
52
DataDir = ?config(data_dir,Config),
53
OutDir = ?config(priv_dir,Config),
54
{ok,CWD} = file:get_cwd(),
55
?line file:set_cwd(filename:join([DataDir,subdir])),
57
%%?line ok=asn1ct:compile(filename:join([DataDir,"../MyMerge.set.asn"]),[{inline,mymerge},{outdir,OutDir}]),
58
?line ok=asn1ct:compile("../MyMerge.set.asn",[{inline,mymerge},{outdir,OutDir}]),
60
?line ok=outfiles_check(OutDir),
61
?line outfiles_remove(OutDir),
63
file:set_cwd(filename:join([DataDir,subdir,subsubdir])),
64
?line ok = asn1ct:compile('../../MyMerge.set.asn',[{inline,mymerge},{i,'..'},{outdir,OutDir}]),
66
?line ok=outfiles_check(OutDir,outfiles2()),
70
ticket_6143(Config) ->
71
DataDir = ?config(data_dir,Config),
72
OutDir = ?config(priv_dir,Config),
73
io:format("DataDir: ~p~n",[DataDir]),
75
?line ok=asn1ct:compile(filename:join([DataDir,"AA1"]),[{i,DataDir},{outdir,OutDir}]),
79
DataDir = ?config(data_dir,Config),
80
OutDir = ?config(priv_dir,Config),
82
code:purge('P-Record'),
83
file:delete(filename:join([OutDir,'P-Record.erl'])),
84
file:delete(filename:join([OutDir,'P-Record.beam'])),
85
?line ok=asn1ct:compile(filename:join([DataDir,"P-Record"]),
86
[noobj,{outdir,OutDir}]),
87
% ?line false = code:is_loaded('P-Record'),
88
?line {ok,_} = file:read_file_info(filename:join([OutDir,
90
?line {error,enoent} =
91
file:read_file_info(filename:join([OutDir,"P-Record.beam"])),
92
?line {ok,_} = c:c(filename:join([OutDir,'P-Record']),
93
[{i,OutDir},{outdir,OutDir}]),
94
?line {file,_} = code:is_loaded('P-Record'),
96
code:purge('P-Record'),
97
code:delete('P-Record'),
98
code:purge('p_record'),
99
code:delete('p_record'),
100
file:delete(filename:join([OutDir,'P-Record.erl'])),
101
file:delete(filename:join([OutDir,'P-Record.beam'])),
102
file:delete(filename:join([OutDir,'p_record.erl'])),
103
file:delete(filename:join([OutDir,'p_record.beam'])),
104
?line ok=asn1ct:compile(filename:join([DataDir,"p_record.set.asn"]),[asn1config,ber_bin,optimize,noobj,{outdir,OutDir}]),
105
%% ?line false = code:is_loaded('P-Record'),
106
%% ?line false = code:is_loaded('p_record'),
107
?line {error,enoent} =
108
file:read_file_info(filename:join([OutDir,"P-Record.beam"])),
109
?line {error,enoent} =
110
file:read_file_info(filename:join([OutDir,"P-Record.erl"])),
111
?line {error,enoent} =
112
file:read_file_info(filename:join([OutDir,"p_record.beam"])),
113
io:format("read_file_info: p_record.erl~n",[]),
115
file:read_file_info(filename:join([OutDir,"p_record.erl"])),
116
io:format("c:c: p_record.erl~n",[]),
117
?line {ok,_} = c:c(filename:join([OutDir,'p_record']),
118
[{i,OutDir},{outdir,OutDir}]),
119
io:format("code:is_loaded: p_record.erl~n",[]),
120
?line {file,_} = code:is_loaded('p_record'),
121
io:format("file:delete: p_record.erl~n",[]),
122
file:delete(filename:join([OutDir,'p_record.erl'])),
123
file:delete(filename:join([OutDir,'p_record.beam'])).
125
verbose(Config) when is_list(Config) ->
126
DataDir = ?config(data_dir,Config),
127
OutDir = ?config(priv_dir,Config),
128
Asn1File = filename:join([DataDir,"Comment.asn"]),
130
%% Test verbose compile
131
?line test_server:capture_start(),
132
?line ok = asn1ct:compile(Asn1File, [{i,DataDir},{outdir,OutDir},noobj,verbose]),
133
?line test_server:capture_stop(),
134
?line [Line0|_] = test_server:capture_get(),
135
?line true = lists:prefix("Erlang ASN.1 version", Line0),
137
%% Test non-verbose compile
138
?line test_server:capture_start(),
139
?line ok = asn1ct:compile(Asn1File, [{i,DataDir},{outdir,OutDir},noobj]),
140
?line test_server:capture_stop(),
141
?line [] = test_server:capture_get(),
144
outfiles_check(OutDir) ->
145
outfiles_check(OutDir,outfiles1()).
148
outfiles_check(_OutDir,[])->
150
outfiles_check(OutDir,[H|T]) ->
151
io:format("File: ~p~n",[filename:join([OutDir,H])]),
152
?line {ok,_}=file:read_file_info(filename:join([OutDir,H])),
153
outfiles_check(OutDir,T).
156
["mymerge.erl","mymerge.beam","MyMerge.asn1db","MyMerge.beam",
157
"MyMerge.erl","MyMerge.hrl"].
159
["MyMerge.beam","mymerge.erl","MyMerge.asn1db","MyMerge.erl",
162
outfiles_remove(OutDir) ->
163
lists:foreach(fun(F)-> file:delete(filename:join([OutDir,F])) end,
166
record_name_prefix(Config) ->
167
DataDir = ?config(data_dir,Config),
168
OutDir = ?config(priv_dir,Config),
169
ok = b_SeqIn(DataDir,OutDir),
170
ok = a_SeqIn(DataDir,OutDir).
172
b_SeqIn(DataDir,OutDir) ->
173
asn1ct:compile(filename:join([DataDir,'Seq']),
174
[{record_name_prefix,"b_"},{outdir,OutDir}]),
175
io:format("FileName: ~p~nOutDir:~p~n",
176
[filename:join([DataDir,'b_SeqIn']),OutDir]),
177
?line {ok,_} = compile:file(filename:join([DataDir,'b_SeqIn']),
179
?line 'b_SeqIn' = b_SeqIn:record_name(),
182
a_SeqIn(DataDir,OutDir) ->
183
asn1ct:compile(filename:join([DataDir,'Seq']),
184
[{record_name_prefix,"a_"},{outdir,OutDir}]),
185
?line {ok,_} = compile:file(filename:join([DataDir,'a_SeqIn']),
187
?line 'a_SeqIn' = a_SeqIn:record_name(),