~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/dialyzer/test/small_tests_SUITE_data/src/toth.erl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-module(toth).
 
2
-export([sys_table_view/1]).
 
3
 
 
4
%%% Constants
 
5
-define(sysTabETS,1).
 
6
-define(sysTabMnesia,2).
 
7
-define(sysTabBoth,3).
 
8
 
 
9
sys_table_view([CpId,{match,Pattern},TableType, ViewType]) ->
 
10
    AllTableList =
 
11
        case TableType of
 
12
            ?sysTabMnesia ->
 
13
                lists:sort(mnesia:system_info(tables));
 
14
            ?sysTabBoth ->
 
15
                lists:sort(rpc:call(CpId,ets,all,[]));
 
16
            ?sysTabETS ->
 
17
                lists:sort(rpc:call(CpId,ets,all,[]) --
 
18
                           mnesia:system_info(tables));
 
19
            _ -> %%% Happens at registration only
 
20
                [ok]
 
21
    end,
 
22
    %% Filter the matching table names, skip unnamed tables first:
 
23
    NamedTableList = lists:filter(fun (X) -> is_atom(X) end, AllTableList),
 
24
    TablesShown =
 
25
        case Pattern of
 
26
            "" ->
 
27
                NamedTableList;
 
28
            _ ->
 
29
                %% Filter the ones whose name begins with the Pattern:
 
30
                Filter = fun(T) ->
 
31
                                 lists:prefix(Pattern, atom_to_list(T))
 
32
                         end,
 
33
                lists:filter(Filter, NamedTableList)   
 
34
        end,
 
35
    
 
36
    Fields = [{text, [{value,"CpId: " ++ atom_to_list(CpId)}]},
 
37
              {text, [{value,"TabSpec=" ++ Pattern},
 
38
                      {value_format, term}]},
 
39
              {text, [{value,"Table type: " ++ formatTableType(TableType)},
 
40
                      {value_format, term}]}],
 
41
 
 
42
    Template = [[{type, index},
 
43
                 {link, {?MODULE, sys_table_browse,
 
44
                         [{"CpId",CpId},{"TableType",TableType}, 
 
45
                          {"View", ViewType},
 
46
                          {"FirstKey",1}, {"KeyPattern",""}]}}],
 
47
                
 
48
                [{type, data},
 
49
                 {title, "Table name"},
 
50
                 {display_value, {erlang, atom_to_list}}], %%% else crash
 
51
                
 
52
                [{type,data},
 
53
                 {title, "No of rows"},
 
54
                 {display_value, term}],
 
55
                
 
56
                [{type,data},
 
57
                 {title, "Memory"},
 
58
                 {display_value, term}]
 
59
               ],
 
60
    
 
61
    TableAttr = [{rows, [[T,T|tableSize(T,TableType,CpId)] ||
 
62
                            T <- TablesShown]},
 
63
                 {template,Template}],
 
64
    
 
65
    Page = [{header, {"Filter tables", "Selected tables"}},
 
66
            {buttons, [reload, back]},
 
67
            {layout, [{form, Fields},
 
68
                      {table, TableAttr}]}
 
69
           ],
 
70
    Page.
 
71
 
 
72
%%--------------------------------------------------------------------
 
73
%% tableSize/3                                    
 
74
%% @spec tableSize(T::atom(),TableType::integer(),CpId::atom()) ->
 
75
%%                 list(integer())
 
76
%% @doc Return the table size and memory size of the table.
 
77
%% @end
 
78
%%---------------------------------------------------------------------
 
79
 
 
80
tableSize(T, TableType, CpId) ->
 
81
    case TableType of
 
82
        ?sysTabETS ->
 
83
            [rpc:call(CpId, ets, info, [T, size]),
 
84
             rpc:call(CpId, ets, info, [T, memory])];
 
85
        ?sysTabMnesia ->
 
86
            [mnesia:table_info(T, size),mnesia:table_info(T, memory)];
 
87
        _ -> %%% Registration
 
88
            [0,0]
 
89
    end.
 
90
 
 
91
formatTableType(T) ->
 
92
    case T of
 
93
        ?sysTabETS ->
 
94
            "ETS";
 
95
        ?sysTabMnesia ->
 
96
            "mnesia";
 
97
        _ -> %%% Registration !
 
98
            "ETS + mnesia"
 
99
    end.